-
Notifications
You must be signed in to change notification settings - Fork 15
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Add InlineMessage * Fix issues with dot notation colors * Bump version
- Loading branch information
1 parent
2687321
commit ff2f4e7
Showing
7 changed files
with
88 additions
and
10 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
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,28 @@ | ||
import { Meta, Story, Canvas } from '@storybook/addon-docs/blocks'; | ||
|
||
import { fAddress } from '../../.jest/__fixtures__'; | ||
import { InlineMessage } from './InlineMessage'; | ||
|
||
<Meta | ||
title="molecules/InlineMessage" | ||
component={InlineMessage} | ||
parameters={{ actions: { argTypesRegex: '^on.*' } }} | ||
argTypes={{ | ||
type: { | ||
control: { | ||
type: 'select', | ||
options: ['success', 'info', 'action', 'warning', 'error'] | ||
} | ||
} | ||
}} | ||
/> | ||
|
||
# InlineMessage | ||
|
||
InlineMessage! | ||
|
||
<Canvas> | ||
<Story name="Default" args={{ type: 'success', children: 'Default' }}> | ||
{(props) => <InlineMessage {...props} />} | ||
</Story> | ||
</Canvas> |
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,8 @@ | ||
import { simpleRender } from '../../.jest/test-utils'; | ||
import { InlineMessage } from './InlineMessage'; | ||
|
||
describe('InlineMessage', () => { | ||
it('renders correctly', () => { | ||
expect(() => simpleRender(<InlineMessage type="error">Foo</InlineMessage>)).not.toThrow(); | ||
}); | ||
}); |
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,33 @@ | ||
import type { FunctionComponent } from 'react'; | ||
import type { DefaultTheme } from 'styled-components'; | ||
import type { SpaceProps } from 'styled-system'; | ||
|
||
import type { IconType } from '../atoms'; | ||
import { Body, Flex, Icon } from '../atoms'; | ||
|
||
export type InlineMessageType = keyof DefaultTheme['colors']['banner']; | ||
|
||
export interface InlineMessageProps extends SpaceProps { | ||
type: InlineMessageType; | ||
} | ||
|
||
const icons: { [key in InlineMessageType]: IconType } = { | ||
success: 'checkmark', | ||
info: 'info', | ||
action: 'waiting', | ||
warning: 'info', | ||
error: 'alert' | ||
}; | ||
|
||
export const InlineMessage: FunctionComponent<InlineMessageProps> = ({ | ||
type, | ||
children, | ||
...props | ||
}) => ( | ||
<Flex display="inline-flex" {...props}> | ||
<Icon type={icons[type]} fill={`banner.${type}`} mr="1" /> | ||
<Body color={`banner.${type}`} as="span" verticalAlign="middle" {...props}> | ||
{children} | ||
</Body> | ||
</Flex> | ||
); |
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