-
-
Notifications
You must be signed in to change notification settings - Fork 185
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(organizations): add theming/story for Mantine TextInput TASK-1378 (
#5424) ### 📣 Summary Add theming and storybook for custom TextInput component. --------- Co-authored-by: Ruth Shryock <[email protected]> Co-authored-by: Paulo Amorim <[email protected]> Co-authored-by: James Kiger <[email protected]>
- Loading branch information
1 parent
8dca2dd
commit f84a9de
Showing
6 changed files
with
170 additions
and
5 deletions.
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,110 @@ | ||
import type {Meta, StoryObj} from '@storybook/react'; | ||
import { TextInput, TextInputProps } from '@mantine/core'; | ||
import Icon from './icon'; | ||
|
||
const inputSizes: Array<TextInputProps['size']> = [ | ||
'sm', | ||
'md', | ||
'lg', | ||
]; | ||
|
||
export default { | ||
title: 'common/TextInput', | ||
component: TextInput, | ||
argTypes: { | ||
label: { | ||
description: 'Appears above the input', | ||
control: 'text', | ||
}, | ||
placeholder: { | ||
description: 'Placeholder text for the input', | ||
control: 'text', | ||
}, | ||
value: { | ||
description: 'Current value of the input', | ||
control: 'text', | ||
}, | ||
onChange: { | ||
description: 'Input value change callback', | ||
}, | ||
size: { | ||
description: | ||
'Changes the size of the component (similar sizing as Button)', | ||
defaultValue: 'md', | ||
options: inputSizes, | ||
control: {type: 'radio'}, | ||
}, | ||
disabled: { | ||
description: 'Disables the input', | ||
control: 'boolean', | ||
}, | ||
required: { | ||
description: 'Marks the input as required', | ||
control: 'boolean', | ||
}, | ||
error: { | ||
description: 'Error message or state for the input', | ||
control: 'text', | ||
}, | ||
}, | ||
} as Meta<typeof TextInput>; | ||
|
||
type Story = StoryObj<typeof TextInput>; | ||
|
||
export const Primary: Story = { | ||
args: { | ||
label: 'Default Text Input', | ||
placeholder: 'Enter text...', | ||
size: 'md', | ||
}, | ||
}; | ||
|
||
export const AutoFocused: Story = { | ||
args: { | ||
label: 'Default Text Input', | ||
placeholder: 'Enter text...', | ||
size: 'md', | ||
autoFocus: true, | ||
}, | ||
}; | ||
|
||
export const Disabled: Story = { | ||
args: { | ||
label: 'Disabled Input', | ||
placeholder: 'You cannot type here', | ||
size: 'md', | ||
disabled: true, | ||
}, | ||
}; | ||
|
||
export const WithError: Story = { | ||
args: { | ||
label: 'Email', | ||
placeholder: 'Enter your email', | ||
value: "not an email", | ||
error: 'Invalid email address', | ||
size: 'md', | ||
}, | ||
}; | ||
|
||
export const WithIconLeft: Story = { | ||
args: { | ||
label: 'Required Input', | ||
placeholder: 'This field is required', | ||
required: true, | ||
withAsterisk: true, | ||
leftSection: <Icon name='user' size='s' />, | ||
size: 'md', | ||
}, | ||
}; | ||
|
||
export const WithIconRight: Story = { | ||
args: { | ||
label: 'Required Input', | ||
placeholder: 'This field is required', | ||
required: true, | ||
withAsterisk: true, | ||
rightSection: <Icon name='user' size='s' />, | ||
size: 'md', | ||
}, | ||
}; |
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,35 @@ | ||
.input:focus-visible:not([data-error]) { | ||
box-shadow: 0 0 0 2px var(--mantine-color-blue-7); | ||
} | ||
|
||
.input { | ||
border-color: var(--mantine-color-gray-6); | ||
|
||
&::placeholder { | ||
color: var(--mantine-color-gray-3); | ||
opacity: 1; | ||
} | ||
} | ||
|
||
.input[data-disabled] { | ||
background-color: var(--mantine-color-gray-7); | ||
border-color: var(--mantine-color-gray-3); | ||
|
||
&::placeholder { | ||
color: var(--mantine-color-gray-2); | ||
} | ||
} | ||
|
||
.input[data-error] { | ||
border-color: var(--mantine-color-red-7); | ||
} | ||
|
||
.section { | ||
color: var(--mantine-color-gray-2); | ||
} | ||
|
||
.label { | ||
font-size: var(--mantine-font-size-xs); | ||
color: var(--mantine-color-gray-1); | ||
margin-bottom: 5px; | ||
} |
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,17 @@ | ||
import classes from './InputBase.module.css'; | ||
import {InputBase} from '@mantine/core'; | ||
|
||
export const InputBaseThemeKobo = InputBase.extend({ | ||
defaultProps: { | ||
size: 'md', | ||
wrapperProps: { | ||
classNames: { | ||
label: classes.label, | ||
}, | ||
}, | ||
classNames: { | ||
input: classes.input, | ||
section: classes.section, | ||
}, | ||
}, | ||
}); |
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