Skip to content
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
2 changes: 1 addition & 1 deletion src/docs/v1/design/designTokens.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -309,7 +309,7 @@ Breakpoint values used to define responsive design thresholds. These tokens help
<i className={styles.tokenFamily}>size:</i> `xs` `sm` `md` `lg` `xl` `xxl`

```css
--theme-grid-breakpoint-xs: 24rem
--theme-grid-breakpoint-xs: 28rem
--theme-grid-breakpoint-sm: 36rem
--theme-grid-breakpoint-md: 48rem
--theme-grid-breakpoint-lg: 62rem
Expand Down
7 changes: 7 additions & 0 deletions src/lib/components/DataView/DataView.module.scss
Original file line number Diff line number Diff line change
Expand Up @@ -136,3 +136,10 @@ $data-view-sizes: ("xs", "sm", "md", "lg", "xl");
}
}
}

@include screen-width("below", "sm") {
.title,
.value {
padding: var(--mtf-sizing-space-8) var(--mtf-sizing-space-12);
}
}
1 change: 0 additions & 1 deletion src/lib/components/Form/Form.stories.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,6 @@ export const Primary: Story = {
label="Which sports"
helperText="Please select at least 2 sports"
groupValidations={[Validations.Required, Validations.AtLeastN(2)]}
wrap
name="sports"
>
<Checkbox label="Football" name="football" checked />
Expand Down
39 changes: 23 additions & 16 deletions src/lib/components/Form/FormFields/FormField.module.scss
Original file line number Diff line number Diff line change
Expand Up @@ -7,35 +7,27 @@ $sizes: (("xs", "xxs", 2, 8, 4, 20), ("sm", "xxs", 4, 12, 6, 24), ("md", "xs", 6
display: flex;
}

// The required mark: before a horizontal label, after a vertical one. The mark comes from the required modifier and its
// place from the label orientation, two axes whose combined selector would exceed the specificity limit (css.md section 4)
// The required mark, always after the label
.required {
--mtf-form-field-mark: "*";
}

.label {
color: var(--mtf-color-text-strong);

&::before,
&::after {
content: var(--mtf-form-field-mark, none);
padding: 0 var(--mtf-sizing-space-2);
color: var(--mtf-color-text-softer);
font-weight: var(--mtf-typography-weight-strongest);
}

.horizontalLabel &::before,
.verticalLabel &::after {
content: var(--mtf-form-field-mark, none);
}

// After the base colors: same specificity, so error and disabled win by order
.error &::before,
.error &::after {
color: var(--mtf-color-danger-text);
}

.disabled &,
.disabled &::before,
.disabled &::after {
color: var(--mtf-color-text-disabled);
}
Expand Down Expand Up @@ -112,7 +104,7 @@ $sizes: (("xs", "xxs", 2, 8, 4, 20), ("sm", "xxs", 4, 12, 6, 24), ("md", "xs", 6

.groupItems {
display: flex;
flex-wrap: nowrap;
flex-wrap: wrap;
Comment thread
hatesalp marked this conversation as resolved.
Resolved
Comment thread
hatesalp marked this conversation as resolved.
Resolved

.horizontalGroup & {
align-items: flex-start;
Expand All @@ -128,10 +120,6 @@ $sizes: (("xs", "xxs", 2, 8, 4, 20), ("sm", "xxs", 4, 12, 6, 24), ("md", "xs", 6
.verticalGroup & {
flex-direction: column;
}

.wrap & {
flex-wrap: wrap;
}
}

@each $size, $helperStep, $gapVLabel, $gapHLabel, $marginTopHLabel, $gapHGroupItems in $sizes {
Expand All @@ -147,7 +135,7 @@ $sizes: (("xs", "xxs", 2, 8, 4, 20), ("sm", "xxs", 4, 12, 6, 24), ("md", "xs", 6
}

&.horizontalLabel {
gap: var(--mtf-sizing-space-#{$gapHLabel});
gap: var(--mtf-sizing-space-#{$gapVLabel}) var(--mtf-sizing-space-#{$gapHLabel});

// The input's vertical padding (its border is drawn inside), so the label lines up with the input's text
.label {
Expand All @@ -172,3 +160,22 @@ $sizes: (("xs", "xxs", 2, 8, 4, 20), ("sm", "xxs", 4, 12, 6, 24), ("md", "xs", 6
}
}
}

@include screen-width("below", "xs") {
.verticalForm.horizontalLabel .label {
width: auto;
min-width: auto;
}

// The label goes above the input, as in vertical labels
.horizontalLabel {
flex-direction: column;
align-items: stretch;
}

@each $size, $helperStep, $gapVLabel, $gapHLabel, $marginTopHLabel, $gapHGroupItems in $sizes {
.#{$size}.horizontalLabel .label {
margin-top: 0;
}
}
}
56 changes: 0 additions & 56 deletions src/lib/components/Form/FormFields/FormFieldGroup.stories.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,6 @@ import type { Meta, StoryObj } from "@storybook/nextjs";
import { Form, Validations } from "../../../index";
import FormFieldGroup from "@/components/Form/FormFields/FormFieldGroup";
import Checkbox from "@/components/Checkbox";
import RadioGroup from "@/components/RadioGroup";
import Radio from "@/components/Radio";
import InputPassword from "@/components/InputPassword";

const meta: Meta<typeof Form.FieldGroup> = {
title: "Components/Form/Form.FieldGroup",
Expand All @@ -13,7 +10,6 @@ const meta: Meta<typeof Form.FieldGroup> = {
name: { control: false },
groupValidations: { control: false },
orientation: { table: { defaultValue: { summary: "horizontal" } } },
wrap: { table: { defaultValue: { summary: "false" } } },
},
args: {
label: "Sports",
Expand Down Expand Up @@ -45,55 +41,3 @@ export const Primary: Story = {
</Form>
),
};

export const SideBySideByDefault: Story = {
parameters: {
docs: {
description: {
story:
"By default (**wrap={false}**), group items are kept on a single line, which is important when grouping a couple of wider items (e.g. a RadioGroup next to an input) that should always sit side by side rather than stack.",
},
},
},
args: {
label: "Gender",
helperText: undefined,
name: "gender",
groupValidations: undefined,
orientation: "horizontal",
},
render: args => (
<Form onSubmit={console.log} formOrientation="horizontal" labelOrientation="horizontal">
<FormFieldGroup {...args}>
<RadioGroup name="gender" orientation="vertical">
<Radio value="male" label="Male" />
<Radio value="female" label="Female" />
</RadioGroup>
<InputPassword name="password" />
</FormFieldGroup>
</Form>
),
};

export const Wrap: Story = {
parameters: {
docs: {
description: {
story:
"Set **wrap={true}** to let group items wrap onto multiple lines when they don't fit on one, which is useful for groups with many small items (e.g. checkboxes) in a narrow container.",
},
},
},
args: {
wrap: true,
},
render: args => (
<Form onSubmit={console.log} style={{ width: 220 }}>
<FormFieldGroup {...args}>
<Checkbox name="football" label="Football" />
<Checkbox name="basketball" label="Basketball" />
<Checkbox name="tennis" label="Tennis" />
</FormFieldGroup>
</Form>
),
};
4 changes: 1 addition & 3 deletions src/lib/components/Form/FormFields/FormFieldGroup.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@ const FormFieldGroup = (props: PropsWithRefAndChildren<FormFieldGroupProps, HTML
label,
helperText,
orientation = "horizontal",
wrap,
groupValidations,
children,
disabled,
Expand All @@ -41,11 +40,10 @@ const FormFieldGroup = (props: PropsWithRefAndChildren<FormFieldGroupProps, HTML
formOrientation + "Form",
labelOrientation + "Label",
orientation + "Group",
wrap && "wrap",
isRequired && "required",
error ? "error" : disabled || readOnly ? "disabled" : success && "success",
]),
[className, disabled, error, formOrientation, isRequired, labelOrientation, orientation, readOnly, size, success, wrap],
[className, disabled, error, formOrientation, isRequired, labelOrientation, orientation, readOnly, size, success],
);

return (
Expand Down
1 change: 0 additions & 1 deletion src/lib/components/Form/FormFields/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,5 +26,4 @@ export type FormFieldGroupProps = Omit<FormFieldProps, "children" | "validations

export type FormFieldGroupDefaultableProps = {
orientation?: "horizontal" | "vertical";
wrap?: boolean;
};
16 changes: 0 additions & 16 deletions src/lib/components/Form/test/Form.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -117,22 +117,6 @@ describe("Form", () => {
expect(getFormFieldGroup(0)).toHaveClass("horizontalGroup");
});

it("should wrap group items when wrap is set as true for Form.FieldGroup", () => {
const formGroup = (wrap?: boolean) => (
<Form onSubmit={mockFunction}>
<Form.FieldGroup name="testGroup" wrap={wrap}>
<InputText key="textInput" name="textInput" />
<InputPassword key="passwordInput" name="passwordInput" />
</Form.FieldGroup>
</Form>
);
const { rerender } = render(formGroup());
expect(getFormFieldGroup(0)).not.toHaveClass("wrap");

rerender(formGroup(true));
expect(getFormFieldGroup(0)).toHaveClass("wrap");
});

it("should display submit button text as given in the submitButtonLabel prop", () => {
const submitButtonLabel = "Submit Form";

Expand Down
6 changes: 3 additions & 3 deletions src/lib/components/Grid/Grid.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -32,15 +32,15 @@ Page size aliases alongside with the container sizes are:
<td>**sm**</td><td>>= 576px</td><td>540px</td>
</tr>
<tr>
<td>**xs**</td><td>>= 384px</td><td>360px</td>
<td>**xs**</td><td>>= 448px</td><td>360px</td>
</tr>
<tr>
<td>**xxs**</td><td>&lt; 384px</td><td>auto</td>
<td>**xxs**</td><td>&lt; 448px</td><td>auto</td>
</tr>
</tbody>
</table>

The **minimum** supported width of the `<Grid>` is **420px** even if the width below 384px is considered as `xxs`.
The **minimum** supported width of the `<Grid>` is **420px** even if the width below 448px is considered as `xxs`.
Most of the contents below 420px might still look good, but it isn't `<Grid>`'s responsibility.

`<Grid>` itself is a pretty simple component which only accepts `<Grid.Row>` as children. In order to correctly place the
Expand Down
6 changes: 6 additions & 0 deletions src/lib/components/Panel/Panel.module.scss
Original file line number Diff line number Diff line change
Expand Up @@ -60,3 +60,9 @@ $title-sizes: (("sm", "md"), ("md", "lg"), ("lg", "xl"));
@include typography("text-#{$step}", "strongest");
}
}

@include screen-width("below", "sm") {
.Root {
padding: var(--mtf-sizing-space-8);
}
}
4 changes: 2 additions & 2 deletions src/lib/components/RadioGroup/RadioGroup.module.scss
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ $sizes: (("xs", 20, 12, 4), ("sm", 24, 16, 6), ("md", 28, 20, 8), ("lg", 32, 24,
}

.horizontal {
flex-direction: row;
flex-flow: row wrap;
}

@each $size, $gapH, $gapV, $paddingV in $sizes {
Expand All @@ -23,7 +23,7 @@ $sizes: (("xs", 20, 12, 4), ("sm", 24, 16, 6), ("md", 28, 20, 8), ("lg", 32, 24,
}

&.horizontal {
gap: var(--mtf-sizing-space-#{$gapH});
gap: var(--mtf-sizing-space-#{$gapV}) var(--mtf-sizing-space-#{$gapH});
}

&.inFormField {
Expand Down
2 changes: 1 addition & 1 deletion src/lib/styles/breakpoints.scss
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

$breakpoints: (
"xxs": 0,
"xs": 24rem,
"xs": 28rem,
Comment thread
aktasmehmet marked this conversation as resolved.
Resolved
"sm": 36rem,
"md": 48rem,
"lg": 62rem,
Expand Down
2 changes: 1 addition & 1 deletion src/lib/styles/themes/default-theme.css
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
--theme-grid-gutter-gutter-sm: 1rem;
--theme-grid-gutter-gutter-xs: 0.5rem;
--theme-grid-gutter-gutter-xxs: 0.25rem;
--theme-grid-breakpoint-xs: 24rem;
--theme-grid-breakpoint-xs: 28rem;
--theme-grid-breakpoint-sm: 36rem;
--theme-grid-breakpoint-md: 48rem;
--theme-grid-breakpoint-lg: 62rem;
Expand Down
2 changes: 1 addition & 1 deletion src/lib/styles/themes/papyrus.css
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
--theme-grid-gutter-gutter-xl: 4rem;
--theme-grid-gutter-gutter-xxl: 8rem;

--theme-grid-breakpoint-xs: 24rem;
--theme-grid-breakpoint-xs: 28rem;
--theme-grid-breakpoint-sm: 36rem;
--theme-grid-breakpoint-md: 48rem;
--theme-grid-breakpoint-lg: 62rem;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@ const FormFieldGroup = (props: PropsWithRefAndChildren<FormFieldGroupProps, HTML
label,
helperText,
orientation = "horizontal",
wrap,
groupValidations,
children,
disabled,
Expand All @@ -41,11 +40,10 @@ const FormFieldGroup = (props: PropsWithRefAndChildren<FormFieldGroupProps, HTML
formOrientation + "Form",
labelOrientation + "Label",
orientation + "Group",
wrap && "wrap",
isRequired && "required",
error ? "error" : disabled || readOnly ? "disabled" : success && "success",
]),
[className, disabled, error, formOrientation, isRequired, labelOrientation, orientation, readOnly, size, success, wrap],
[className, disabled, error, formOrientation, isRequired, labelOrientation, orientation, readOnly, size, success],
);

return (
Expand Down
Loading