Skip to content

Commit 9b59a96

Browse files
authored
fix(forms): updates Message to receive margin when intermediaries are present (#1799)
1 parent e2cd75f commit 9b59a96

File tree

3 files changed

+40
-7
lines changed

3 files changed

+40
-7
lines changed

packages/datepickers/demo/datepicker.stories.mdx

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,12 @@ import README from '../README.md';
1616
<Canvas>
1717
<Story
1818
name="Datepicker"
19-
args={{ dateStyle: DATE_STYLE_OPTIONS[1], eventsEnabled: true, isAnimated: true }}
19+
args={{
20+
dateStyle: DATE_STYLE_OPTIONS[1],
21+
eventsEnabled: true,
22+
isAnimated: true,
23+
message: 'Message'
24+
}}
2025
argTypes={{
2126
value: { control: 'date' },
2227
minValue: { control: 'date' },
@@ -25,6 +30,17 @@ import README from '../README.md';
2530
control: 'radio',
2631
options: DATE_STYLE_OPTIONS,
2732
table: { category: 'Story' }
33+
},
34+
hasMessage: { name: 'Message', control: { type: 'boolean' }, table: 'Story' },
35+
message: { name: 'children', control: { type: 'text' }, table: { category: 'Message' } },
36+
validation: {
37+
options: ['success', 'warning', 'error'],
38+
control: { type: 'radio' },
39+
table: { category: 'Input' }
40+
},
41+
validationLabel: {
42+
control: { type: 'text' },
43+
table: { category: 'Message' }
2844
}
2945
}}
3046
parameters={{

packages/datepickers/demo/stories/DatepickerStory.tsx

Lines changed: 22 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -8,27 +8,44 @@
88
import React from 'react';
99
import { Story } from '@storybook/react';
1010
import { Col, Grid, Row } from '@zendeskgarden/react-grid';
11-
import { Field, Input, Label } from '@zendeskgarden/react-forms';
11+
import { Field, Input, Label, Message } from '@zendeskgarden/react-forms';
1212
import { Datepicker, IDatepickerProps } from '@zendeskgarden/react-datepickers';
1313
import { DATE_STYLE } from './types';
1414

1515
interface IArgs extends IDatepickerProps {
1616
dateStyle: DATE_STYLE;
17+
hasMessage?: boolean;
18+
message?: string;
19+
validation?: 'success' | 'warning' | 'error';
20+
validationLabel?: string;
1721
}
1822

19-
export const DatepickerStory: Story<IArgs> = ({ dateStyle, isCompact, ...args }) => {
23+
export const DatepickerStory: Story<IArgs> = ({
24+
dateStyle,
25+
isCompact,
26+
hasMessage,
27+
message,
28+
validation,
29+
validationLabel,
30+
...args
31+
}) => {
2032
const formatDate = (date: Date) =>
2133
new Intl.DateTimeFormat(args.locale, { dateStyle }).format(date);
2234

2335
return (
2436
<Grid>
25-
<Row style={{ height: 'calc(100vh - 80px)' }}>
26-
<Col textAlign="center" alignSelf="center">
37+
<Row justifyContent="center" style={{ height: 'calc(100vh - 80px)' }}>
38+
<Col alignSelf="center">
2739
<Field>
2840
<Label hidden>{Datepicker.displayName}</Label>
2941
<Datepicker {...args} formatDate={formatDate} isCompact={isCompact}>
30-
<Input isCompact={isCompact} style={{ width: isCompact ? 256 : 320 }} />
42+
<Input isCompact={isCompact} validation={validation} />
3143
</Datepicker>
44+
{hasMessage && (
45+
<Message validation={validation} validationLabel={validationLabel}>
46+
{message}
47+
</Message>
48+
)}
3249
</Field>
3350
</Col>
3451
</Row>

packages/forms/src/styled/text/StyledTextInput.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -193,7 +193,7 @@ const sizeStyles = (props: IStyledTextInputProps & ThemeProps<DefaultTheme>) =>
193193
${StyledHint} + &&,
194194
${StyledMessage} + &&,
195195
&& + ${StyledHint},
196-
&& + ${StyledMessage} {
196+
&& ~ ${StyledMessage} {
197197
margin-top: ${props.theme.space.base * (props.isCompact ? 1 : 2)}px;
198198
}
199199
/* stylelint-enable */

0 commit comments

Comments
 (0)