Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 0 additions & 8 deletions playwright/components/textarea/index.ts

This file was deleted.

4 changes: 0 additions & 4 deletions playwright/components/textarea/locators.ts

This file was deleted.

720 changes: 298 additions & 422 deletions skills/carbon-react/components/textarea.md

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion skills/carbon-react/components/time.md
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ description: Carbon Time component props and usage examples.
| onBlur | ((ev?: React.FocusEvent<HTMLInputElement>, value?: TimeValue) => void) \| undefined | No | | | | Callback called when focus is lost on input elements | |
| readOnly | boolean \| undefined | No | | | | If true, the component will be read-only | |
| required | boolean \| undefined | No | | | | Flag to configure component as mandatory | |
| size | Sizes \| undefined | No | small \| medium \| large | | | Sets the size of the inputs | "medium" |
| size | "small" \| "medium" \| "large" \| undefined | No | small \| medium \| large | | | Sets the size of the inputs | "medium" |
| toggleProps | ToggleDataProps \| undefined | No | | | | Set custom data- attributes on the toggle elements | {} |
| validationMessagePositionTop | boolean \| undefined | No | | | | Render the ValidationMessage above the Time inputs | true |
| data-element | string \| undefined | No | | | | Identifier used for testing purposes, applied to the root element of the component. | |
Expand Down
12 changes: 4 additions & 8 deletions src/__internal__/character-count/character-count.component.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import React from "react";

import {
StyledCharacterCountWrapper,
StyledCharacterCount,
VisuallyHiddenCharacterCount,
VisuallyHiddenHint,
Expand All @@ -16,8 +15,6 @@ interface CharacterCountProps {
isDebouncedOverLimit?: boolean;
isOverLimit: boolean;
visuallyHiddenHintId?: string;
/** Set large font-size */
isLarge?: boolean;
size?: "small" | "medium" | "large";
disabled?: boolean;
}
Expand All @@ -30,8 +27,7 @@ const CharacterCount = ({
isDebouncedOverLimit,
isOverLimit,
visuallyHiddenHintId,
isLarge,
size,
size = "medium",
disabled = false,
}: CharacterCountProps) => {
const limitMinusValue: number = +limit - +value;
Expand All @@ -44,7 +40,7 @@ const CharacterCount = ({
new Intl.NumberFormat(locale).format(rawValue);

return (
<StyledCharacterCountWrapper>
<div>
<VisuallyHiddenHint
data-element="visually-hidden-hint"
data-role="visually-hidden-hint"
Expand All @@ -59,9 +55,9 @@ const CharacterCount = ({
isOverLimit={isOverLimit}
data-element="character-count"
data-role="character-count"
isLarge={isLarge}
$size={size}
$disabled={disabled}
aria-disabled={disabled}
Comment thread
ibutakova marked this conversation as resolved.
Resolved
>
{!isOverLimit
? l.characterCount.charactersLeft(
Expand All @@ -88,7 +84,7 @@ const CharacterCount = ({
getFormatNumber(debouncedValueMinusLimit, l.locale()),
)}
</VisuallyHiddenCharacterCount>
</StyledCharacterCountWrapper>
</div>
);
};

Expand Down
56 changes: 31 additions & 25 deletions src/__internal__/character-count/character-count.style.ts
Original file line number Diff line number Diff line change
@@ -1,40 +1,47 @@
import styled, { css } from "styled-components";

import applyBaseTheme from "../../style/themes/apply-base-theme";
import visuallyHidden from "../../style/utils/visually-hidden";

import { getFont } from "../../components/textarea/textarea.style";
import type { TextAreaSize } from "../../components/textarea/textarea.style";

const StyledCharacterCountWrapper = styled.div``;
const sizeMap = {
small: {
font: "var(--global-font-static-comp-regular-s)",
fontOverLimit: "var(--global-font-static-comp-medium-s)",
paddingTop: "var(--global-space-comp-xs)",
},
medium: {
font: "var(--global-font-static-comp-regular-m)",
fontOverLimit: "var(--global-font-static-comp-medium-m)",
paddingTop: "var(--global-space-comp-xs)",
},
large: {
font: "var(--global-font-static-comp-regular-l)",
fontOverLimit: "var(--global-font-static-comp-medium-l)",
paddingTop: "var(--global-space-comp-s)",
},
};

const StyledCharacterCount = styled.div.attrs(applyBaseTheme)<{
isOverLimit: boolean;
isLarge?: boolean;
$size?: TextAreaSize;
$size: "small" | "medium" | "large";
$disabled?: boolean;
}>`
text-align: left;
${({ $size }) => getFont($size || "medium", "regular")};
margin: ${({ $size }) =>
`${$size === "large" ? "var(--global-space-comp-s)" : "var(--global-space-comp-xs)"} 0px`};
color: ${({ isOverLimit, $disabled }) =>
$disabled
? "var(--input-typical-txt-disabled)"
: isOverLimit
? " var(--input-validation-label-error)"
: "var(--input-typical-txt-alt)"};
${({ isOverLimit, $size, $disabled }) => css`
text-align: left;
color: var(--input-typical-txt-alt);
font: ${sizeMap[$size].font};
padding-top: ${sizeMap[$size].paddingTop};

${({ isLarge }) =>
isLarge &&
${isOverLimit &&
css`
font: var(--global-font-static-comp-regular-l);
`}
${({ isOverLimit, $size }) =>
isOverLimit &&
font: ${sizeMap[$size].fontOverLimit};
color: var(--input-validation-label-error);
Comment thread
nuria1110 marked this conversation as resolved.
Resolved
`};

${$disabled &&
css`
${getFont($size || "medium", "medium")};
color: var(--input-typical-txt-disabled);
`}
`}
`;

const VisuallyHiddenCharacterCount = styled.div`
Expand All @@ -58,7 +65,6 @@ const VisuallyHiddenHint = styled.div`
`;

export {
StyledCharacterCountWrapper,
StyledCharacterCount,
VisuallyHiddenCharacterCount,
VisuallyHiddenHint,
Expand Down
22 changes: 0 additions & 22 deletions src/__internal__/character-count/character-count.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -121,28 +121,6 @@ test("visually hidden hint renders with 'you can enter up to {count} character(s
);
});

// coverage
test("renders with expected styles when `isLarge` is true", () => {
render(<CharacterCount isLarge value={5} limit={10} isOverLimit={false} />);

expect(screen.getByTestId("character-count")).toHaveStyleRule(
"font",
"var(--global-font-static-comp-regular-l)",
);
});

// coverage
test("renders with expected styles when `size` is large", () => {
render(
<CharacterCount size="large" value={5} limit={10} isOverLimit={false} />,
);

expect(screen.getByTestId("character-count")).toHaveStyleRule(
"margin",
"var(--global-space-comp-s) 0px",
);
});

test("disabled character count uses correct color token", () => {
render(<CharacterCount disabled value={10} limit={5} isOverLimit={false} />);

Expand Down
3 changes: 1 addition & 2 deletions src/__internal__/legacy-input/index.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,9 @@
import Input from "./input.component";
import InputPresentation from "./input-presentation.component";

export type {
InputProps,
CommonInputProps,
EnterKeyHintTypes,
} from "./input.component";
export { Input, InputPresentation };
export { Input };
export default Input;
110 changes: 0 additions & 110 deletions src/__internal__/legacy-input/input-presentation.component.tsx

This file was deleted.

Loading
Loading