-
Notifications
You must be signed in to change notification settings - Fork 65
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
✨ Adornments support in
Input
component (#2354)
* 🚧 WIP * 📝 Added story * wip * 🚧 WIP * 🚧 WIP * 🚧 wip * 🚚 Moved over `Input` adornment changes * ♻️ Added `OldInput` for interim development * 🐛 Fixed textarea outline * ♻️ back to new input * 🔥 removed OldInput * Testing something old * updated snapshots * its something * ♻️ working version before testing styles * ♻️ Further testing and tweaking * 📸 ✅ Updated test & snapshots * ♻️ working example * 🚚 Moved typographymixin * ♻️ Started cleaning up helpertext
- Loading branch information
Showing
6 changed files
with
180 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
62 changes: 62 additions & 0 deletions
62
packages/eds-core-react/src/components/InputWrapper/HelperText/HelperText.token.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,62 @@ | ||
import { tokens } from '@equinor/eds-tokens' | ||
import type { Spacing, Typography } from '@equinor/eds-tokens' | ||
|
||
const { | ||
colors, | ||
spacings: { comfortable }, | ||
typography, | ||
} = tokens | ||
|
||
export type HelperTextProps = { | ||
background: string | ||
typography: Typography | ||
spacings: { | ||
comfortable: Spacing | ||
compact: Spacing | ||
} | ||
} | ||
|
||
export const helperText: HelperTextProps = { | ||
background: colors.ui.background__light.hex, | ||
typography: { | ||
...typography.input.helper, | ||
color: colors.text.static_icons__tertiary.rgba, | ||
}, | ||
spacings: { | ||
comfortable: { | ||
left: comfortable.small, | ||
right: comfortable.small, | ||
top: comfortable.small, | ||
bottom: '6px', | ||
}, | ||
compact: { | ||
left: comfortable.small, | ||
right: comfortable.small, | ||
top: comfortable.xx_small, | ||
bottom: '6px', | ||
}, | ||
}, | ||
} | ||
|
||
const colorVariants = { | ||
default: { | ||
color: colors.text.static_icons__tertiary.hex, | ||
disabledColor: colors.interactive.disabled__text.hex, | ||
focusColor: colors.text.static_icons__tertiary.hex, | ||
}, | ||
error: { | ||
color: colors.interactive.danger__text.hex, | ||
disabledColor: colors.interactive.disabled__text.hex, | ||
focusColor: colors.interactive.danger__hover.hex, | ||
}, | ||
warning: { | ||
color: colors.interactive.warning__text.hex, | ||
disabledColor: colors.interactive.disabled__text.hex, | ||
focusColor: colors.interactive.warning__hover.hex, | ||
}, | ||
success: { | ||
color: colors.interactive.success__text.hex, | ||
disabledColor: colors.interactive.disabled__text.hex, | ||
focusColor: colors.interactive.success__hover.hex, | ||
}, | ||
} |
52 changes: 52 additions & 0 deletions
52
packages/eds-core-react/src/components/InputWrapper/HelperText/HelperText.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
import { forwardRef, ReactNode, HTMLAttributes } from 'react' | ||
import styled, { css } from 'styled-components' | ||
import { typographyMixin } from '@equinor/eds-utils' | ||
import { helperText as tokens } from './HelperText.token' | ||
|
||
type ContainerProps = { | ||
color?: string | ||
} | ||
|
||
const Container = styled.div<ContainerProps>(({ color }) => | ||
css({ | ||
display: 'grid', | ||
gap: '8px', | ||
gridAutoFlow: 'column', | ||
alignItems: 'start', | ||
justifyContent: 'start', | ||
color, | ||
}), | ||
) | ||
const Text = styled.p` | ||
margin: 0; | ||
${typographyMixin(tokens.typography)}; | ||
` | ||
|
||
type HelperTextProps = { | ||
/** Helper text */ | ||
text?: string | ||
/** Icon */ | ||
icon?: ReactNode | ||
/** Color */ | ||
color?: string | ||
} & HTMLAttributes<HTMLDivElement> | ||
|
||
const TextfieldHelperText = forwardRef<HTMLDivElement, HelperTextProps>( | ||
function TextfieldHelperText( | ||
{ text, icon, color = tokens.typography.color, ...rest }, | ||
ref, | ||
) { | ||
if (!text) { | ||
return null | ||
} | ||
|
||
return ( | ||
<Container {...{ ...rest, color, ref }}> | ||
{icon} | ||
<Text>{text}</Text> | ||
</Container> | ||
) | ||
}, | ||
) | ||
|
||
export { TextfieldHelperText as HelperText } |
1 change: 1 addition & 0 deletions
1
packages/eds-core-react/src/components/InputWrapper/HelperText/index.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
export { HelperText } from './HelperText' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters