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

✨ Input: Added css-variable to override background #2718

Merged
merged 2 commits into from
Jan 12, 2023
Merged
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
5 changes: 5 additions & 0 deletions packages/eds-core-react/src/components/Input/Input.docs.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -63,3 +63,8 @@ Compact `Input` using `EdsProvider`.


<Story id="inputs-input--casted" />

### Override input background color
Use custom property `--eds-input-background` to change the background color of the input field. This also works for all components using input internally: `Autocomplete`, `Textfield`, `Search` and `Textarea`

<Story id="inputs-input--override-background" />
18 changes: 18 additions & 0 deletions packages/eds-core-react/src/components/Input/Input.stories.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -250,3 +250,21 @@ export const WithAdornments: Story<InputProps> = () => {
export const casted: Story<InputProps> = (args) => {
return <Input as="textarea" {...args} />
}

export const OverrideBackground: Story<InputProps> = (args) => {
return (
<Input
style={{ '--eds-input-background': '#fff' } as React.CSSProperties}
{...args}
/>
)
}
OverrideBackground.decorators = [
(Story) => {
return (
<Stack style={{ background: '#f7f7f7', padding: '32px' }}>
<Story />
</Stack>
)
},
]
2 changes: 1 addition & 1 deletion packages/eds-core-react/src/components/Input/Input.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ const Container = styled.div(({ token, disabled, readOnly }: StyledProps) => {
border: none;
box-sizing: border-box;
box-shadow: ${token.boxShadow};
background: ${token.background};
background: var(--eds-input-background, ${token.background});
${outlineTemplate(token.outline)}

&:focus-within {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ exports[`Input Matches snapshot 1`] = `
border: none;
box-sizing: border-box;
box-shadow: inset 0px -1px 0px 0px var(--eds_text__static_icons__tertiary,rgba(111,111,111,1));
background: var(--eds_ui_background__light,rgba(247,247,247,1));
background: var(--eds-input-background,var(--eds_ui_background__light,rgba(247,247,247,1)));
outline: 1px solid transparent;
outline-offset: 0px;
background: transparent;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ exports[`Search Matches snapshot 1`] = `
border: none;
box-sizing: border-box;
box-shadow: inset 0px -1px 0px 0px var(--eds_text__static_icons__tertiary,rgba(111,111,111,1));
background: var(--eds_ui_background__light,rgba(247,247,247,1));
background: var(--eds-input-background,var(--eds_ui_background__light,rgba(247,247,247,1)));
outline: 1px solid transparent;
outline-offset: 0px;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ exports[`TextField Matches snapshot 1`] = `
border: none;
box-sizing: border-box;
box-shadow: inset 0px -1px 0px 0px var(--eds_text__static_icons__tertiary,rgba(111,111,111,1));
background: var(--eds_ui_background__light,rgba(247,247,247,1));
background: var(--eds-input-background,var(--eds_ui_background__light,rgba(247,247,247,1)));
outline: 1px solid transparent;
outline-offset: 0px;
}
Expand Down