Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Disp 139/input #468

Merged
merged 8 commits into from
Sep 19, 2024
Merged
Show file tree
Hide file tree
Changes from 6 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
136 changes: 0 additions & 136 deletions src/components/experimental/Input/Input.tsx

This file was deleted.

21 changes: 0 additions & 21 deletions src/components/experimental/Input/docs/Input.stories.tsx

This file was deleted.

25 changes: 25 additions & 0 deletions src/components/experimental/TextField/ClearButton.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
import React, { ReactElement } from 'react';
import styled from 'styled-components';
import { Button as BaseButton, ButtonProps as BaseButtonProps } from 'react-aria-components';
import { getSemanticValue } from '../../../essentials/experimental/cssVariables';
import { XCrossCircleIcon } from '../../../icons';

const StyledButton = styled(BaseButton)`
appearance: none;
background: none;
border: none;
display: flex;
margin: 0;
padding: 0;
color: ${getSemanticValue('on-surface-variant')};
alatielle marked this conversation as resolved.
Show resolved Hide resolved
`;

function ClearButton(props: BaseButtonProps): ReactElement {
return (
<StyledButton {...props}>
<XCrossCircleIcon />
</StyledButton>
);
}

export { ClearButton };
41 changes: 41 additions & 0 deletions src/components/experimental/TextField/Field.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
import { Input as BaseInput, TextArea as BaseTextArea } from 'react-aria-components';
import styled, { css } from 'styled-components';
import { getSemanticValue } from '../../../essentials/experimental/cssVariables';
import { textStyles } from '../Text/Text';

const fieldStyles = css`
border: none;
background-color: unset;
outline: none;

display: block;
width: 100%;
padding: 0;

caret-color: ${getSemanticValue('interactive')};
color: ${getSemanticValue('on-surface')};

${textStyles.variants.body1}

&::placeholder {
color: ${getSemanticValue('on-surface-variant')};
}
`;

// TODO: Implement autogrow
export const TextArea = styled(BaseTextArea).attrs({ rows: 1 })`
${fieldStyles};

resize: none;
min-height: ${textStyles.variants.body1.lineHeight};
`;

export const Input = styled(BaseInput)`
${fieldStyles}

&[type='search'] {
&::-webkit-search-cancel-button {
alatielle marked this conversation as resolved.
Show resolved Hide resolved
display: none;
}
}
`;
25 changes: 25 additions & 0 deletions src/components/experimental/TextField/Label.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
import { Label as BaseLabel } from 'react-aria-components';
import styled, { css } from 'styled-components';
import { textStyles } from '../Text/Text';

export const flyingLabelStyles = css`
top: 0;
transform: translate3d(0, 0, 0);

${textStyles.variants.label2}
`;

export const Label = styled(BaseLabel)<{ $flying: boolean }>`
position: absolute;
top: 50%;
color: currentColor;

${textStyles.variants.body1}

transform: translate3d(0, calc(-${textStyles.variants.body1.lineHeight} / 2), 0);
transform-origin: 0;

transition: top 200ms ease, font-size 200ms ease, transform 200ms ease;
alatielle marked this conversation as resolved.
Show resolved Hide resolved

${props => props.$flying && flyingLabelStyles}
alatielle marked this conversation as resolved.
Show resolved Hide resolved
`;
Loading