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

feat(organizations): add theming/story for Mantine TextInput TASK-1378 #5424

Merged
merged 29 commits into from
Jan 29, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
29 commits
Select commit Hold shift + click to select a range
3105f47
refactor(frontend): add Mantine Component Library
Akuukis Dec 11, 2024
453f2c1
wip(frontend): example mantine usage
Akuukis Dec 11, 2024
15b3557
refactor(theme): rename theme
Akuukis Dec 12, 2024
d782e38
refactor(theme): style Button
Akuukis Dec 12, 2024
eca5c85
wip: TODO before merge
Akuukis Dec 12, 2024
cde2874
refactor(theme): extend Button with tooltip
Akuukis Dec 12, 2024
7142d55
Merge branch 'main' into kalvis/mantine-setup
magicznyleszek Dec 16, 2024
511b407
Fix Checkbox component misaligned element caused by Mantine's CSS Reset
magicznyleszek Dec 16, 2024
27e8f95
setup Storybook for Mantine by following official guide
magicznyleszek Dec 18, 2024
2df7caa
improve gray color comments from Mantine theme
magicznyleszek Dec 18, 2024
717f080
Merge branch 'main' into kalvis/mantine-setup
magicznyleszek Dec 18, 2024
b5695da
Merge branch 'main' into kalvis/mantine-setup
magicznyleszek Dec 19, 2024
af2517c
Merge branch 'main' of github.com:kobotoolbox/kpi into kalvis/mantine…
magicznyleszek Dec 30, 2024
29c9092
Merge branch 'kalvis/mantine-setup' of github.com:kobotoolbox/kpi int…
magicznyleszek Dec 30, 2024
9293760
Merge branch 'main' into kalvis/mantine-setup
magicznyleszek Jan 4, 2025
d4dea03
refactor(SimpleTable): drop BEM, use Mantine TASK-1377 (#5366)
magicznyleszek Jan 6, 2025
bafb0be
Merge branch 'main' into kalvis/mantine-setup
magicznyleszek Jan 6, 2025
3e62d24
feat(organizations): add mantine menu theme/story TASK-1382 (#5410)
jamesrkiger Jan 8, 2025
4691dde
Remove todo comment
jamesrkiger Jan 14, 2025
4df19e6
Merge branch 'main' of github.com:kobotoolbox/kpi into task-1378-mant…
RuthShryock Jan 15, 2025
fc6fe0c
Merge branch 'main' of github.com:kobotoolbox/kpi into task-1378-mant…
RuthShryock Jan 16, 2025
047844e
added wrapped mantine TextInput componenet with styling and storybook
RuthShryock Jan 16, 2025
3aa2883
add setValue
RuthShryock Jan 16, 2025
54f1976
Resolve merge conflicts
jamesrkiger Jan 22, 2025
11f4c62
Move theming and configuration to Input and InputWrapper components
jamesrkiger Jan 22, 2025
4d9a78b
Remove wrapped TextInput, add theming through InputBase and css module
jamesrkiger Jan 28, 2025
9073cb0
Resolve merge conflicts
jamesrkiger Jan 28, 2025
b3c11a1
Update jsapp/js/theme/kobo/InputBase.ts
jamesrkiger Jan 29, 2025
985bf49
Delete outdated input wrapper theming
jamesrkiger Jan 29, 2025
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
2 changes: 1 addition & 1 deletion jsapp/js/components/common/textBox.stories.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ const textBoxTypes: TextBoxType[] = [
const textBoxSizes: TextBoxSize[] = ['s', 'm', 'l'];

export default {
title: 'common/TextBox',
title: 'commonDeprecated/TextBox',
component: TextBox,
description:
'This is a component that displays an input. It uses most of the browser built-in functionalities.',
Expand Down
1 change: 1 addition & 0 deletions jsapp/js/components/common/textBox.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,7 @@ interface TextBoxProps {
/**
* A generic text box component. It relies on parent to handle all the data
* updates.
* * @deprecated Use mantine inputs
*/
export default function TextBox(props: TextBoxProps) {
const inputReference: React.MutableRefObject<null | HTMLInputElement> =
Expand Down
110 changes: 110 additions & 0 deletions jsapp/js/components/common/textInput.stories.tsx
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',
},
};
35 changes: 35 additions & 0 deletions jsapp/js/theme/kobo/InputBase.module.css
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;
}
17 changes: 17 additions & 0 deletions jsapp/js/theme/kobo/InputBase.ts
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,
},
},
});
10 changes: 6 additions & 4 deletions jsapp/js/theme/kobo/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import {createTheme, rem} from '@mantine/core';
import {ActionIconThemeKobo} from './ActionIcon';
import {ButtonThemeKobo} from './Button';
import {TableThemeKobo} from './Table';
import {InputBaseThemeKobo} from './InputBase';
import {TooltipThemeKobo} from './Tooltip';
import {MenuThemeKobo} from './Menu';
import {AlertThemeKobo} from './Alert';
Expand Down Expand Up @@ -79,7 +80,7 @@ export const themeKobo = createTheme({
fontFamily: '"Roboto", sans-serif',
fontFamilyMonospace: 'Roboto Mono, monospace',
fontSizes: {
xs: rem(11), // TODO: For now implied from button sizes.
xs: rem(12),
sm: rem(13), // TODO: For now implied from button sizes.
md: rem(14), // TODO: For now implied from button sizes.
lg: rem(16),
Expand All @@ -106,11 +107,12 @@ export const themeKobo = createTheme({
ActionIcon: ActionIconThemeKobo,
Alert: AlertThemeKobo,
Button: ButtonThemeKobo,
InputBase: InputBaseThemeKobo,
Loader: LoaderThemeKobo,
Menu: MenuThemeKobo,
Modal: ModalThemeKobo,
Select: SelectThemeKobo,
Tooltip: TooltipThemeKobo,
Table: TableThemeKobo,
Select: SelectThemeKobo,
Loader: LoaderThemeKobo,
Modal: ModalThemeKobo,
},
});