From bbe26c97f692bcc77c3177a0fcd607102143dbe8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Pavel=20Lu=C4=8Div=C5=88=C3=A1k?= Date: Fri, 26 Jul 2019 16:08:24 +0200 Subject: [PATCH 1/6] make Icon "name" prop required --- packages/react/src/components/Icon/Icon.tsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/react/src/components/Icon/Icon.tsx b/packages/react/src/components/Icon/Icon.tsx index 60a9c5d7f3..e1ac1f4846 100644 --- a/packages/react/src/components/Icon/Icon.tsx +++ b/packages/react/src/components/Icon/Icon.tsx @@ -30,7 +30,7 @@ export interface IconProps extends UIComponentProps, ColorComponentProps { disabled?: boolean /** Name of the icon. */ - name?: string + name: string /** An icon can provide an outline variant. */ outline?: boolean From 3d661ff38ad953ed5fafefa0c870d1ff082cae04 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Pavel=20Lu=C4=8Div=C5=88=C3=A1k?= Date: Fri, 26 Jul 2019 16:14:36 +0200 Subject: [PATCH 2/6] update changelog --- CHANGELOG.md | 1 + 1 file changed, 1 insertion(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 78ef66032d..fd98a0bb90 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -48,6 +48,7 @@ This project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.htm - `Loader` uses `Text` component for `label` slot instead of `Box` @layershifter ([#1701](https://github.com/stardust-ui/react/pull/1701)) - Fix test cut off in `Button` component @layershifter ([#1716](https://github.com/stardust-ui/react/pull/1716)) - Close `Toolbar`'s menu when it looses focus @sophieH29 ([#1688](https://github.com/stardust-ui/react/pull/1688)) +- Fix `Icon` `name` prop not required @lucivpav ([#1723](https://github.com/stardust-ui/react/pull/1723)) ### Documentation - Make sidebar categories collapsible @lucivpav ([#1611](https://github.com/stardust-ui/react/pull/1611)) From f40065861b3415b69b47f9d02316272b42d2e2bb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Pavel=20Lu=C4=8Div=C5=88=C3=A1k?= Date: Fri, 26 Jul 2019 16:41:46 +0200 Subject: [PATCH 3/6] Update CHANGELOG.md Co-Authored-By: Oleksandr Fediashov --- CHANGELOG.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index fd98a0bb90..59ae03c2cc 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -48,7 +48,7 @@ This project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.htm - `Loader` uses `Text` component for `label` slot instead of `Box` @layershifter ([#1701](https://github.com/stardust-ui/react/pull/1701)) - Fix test cut off in `Button` component @layershifter ([#1716](https://github.com/stardust-ui/react/pull/1716)) - Close `Toolbar`'s menu when it looses focus @sophieH29 ([#1688](https://github.com/stardust-ui/react/pull/1688)) -- Fix `Icon` `name` prop not required @lucivpav ([#1723](https://github.com/stardust-ui/react/pull/1723)) +- Require `name` prop in `Icon` component @lucivpav ([#1723](https://github.com/stardust-ui/react/pull/1723)) ### Documentation - Make sidebar categories collapsible @lucivpav ([#1611](https://github.com/stardust-ui/react/pull/1611)) From e0d1be5351ed06b721e988904f5e448e20018999 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Pavel=20Lu=C4=8Div=C5=88=C3=A1k?= Date: Fri, 26 Jul 2019 16:55:01 +0200 Subject: [PATCH 4/6] update propTypes --- packages/react/src/components/Icon/Icon.tsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/react/src/components/Icon/Icon.tsx b/packages/react/src/components/Icon/Icon.tsx index e1ac1f4846..77ece1ee93 100644 --- a/packages/react/src/components/Icon/Icon.tsx +++ b/packages/react/src/components/Icon/Icon.tsx @@ -61,7 +61,7 @@ class Icon extends UIComponent, any> { bordered: PropTypes.bool, circular: PropTypes.bool, disabled: PropTypes.bool, - name: PropTypes.string, + name: PropTypes.string.isRequired, outline: PropTypes.bool, rotate: PropTypes.number, size: customPropTypes.size, From 231046e29db553cf64c62bed19d0f17600d593f9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Pavel=20Lu=C4=8Div=C5=88=C3=A1k?= Date: Mon, 29 Jul 2019 17:11:25 +0200 Subject: [PATCH 5/6] fix failing tests --- .../test/specs/commonTests/implementsShorthandProp.tsx | 7 ++++++- .../test/specs/components/Attachment/Attachment-test.tsx | 5 ++++- .../react/test/specs/components/Button/Button-test.tsx | 5 ++++- packages/react/test/specs/components/Icon/Icon-test.tsx | 5 ++++- packages/react/test/specs/components/Input/Input-test.tsx | 5 ++++- packages/react/test/specs/components/Label/Label-test.tsx | 5 ++++- 6 files changed, 26 insertions(+), 6 deletions(-) diff --git a/packages/react/test/specs/commonTests/implementsShorthandProp.tsx b/packages/react/test/specs/commonTests/implementsShorthandProp.tsx index 0df0581144..e23bd1d553 100644 --- a/packages/react/test/specs/commonTests/implementsShorthandProp.tsx +++ b/packages/react/test/specs/commonTests/implementsShorthandProp.tsx @@ -5,6 +5,7 @@ import { Props, PropsOf, InstanceOf } from 'src/types' export type ShorthandTestOptions = { mapsValueToProp: keyof (TProps & React.HTMLProps) | false + requiredProps?: any } export const DefaultShorthandTestOptions: ShorthandTestOptions = { @@ -65,7 +66,11 @@ export default ((Component: React.ComponentType) => { } test(`object value is spread as ${displayName}'s props`, () => { - expectShorthandPropsAreHandled({ foo: 'foo value', bar: 'bar value' }) + expectShorthandPropsAreHandled({ + ...options.requiredProps, + foo: 'foo value', + bar: 'bar value', + }) }) }) } diff --git a/packages/react/test/specs/components/Attachment/Attachment-test.tsx b/packages/react/test/specs/components/Attachment/Attachment-test.tsx index fb55285283..66b260fffc 100644 --- a/packages/react/test/specs/components/Attachment/Attachment-test.tsx +++ b/packages/react/test/specs/components/Attachment/Attachment-test.tsx @@ -28,7 +28,10 @@ describe('Attachment', () => { isConformant(Attachment) attachmentImplementsShorthandProp('header', Text) attachmentImplementsShorthandProp('description', Text) - attachmentImplementsShorthandProp('icon', Icon, { mapsValueToProp: 'name' }) + attachmentImplementsShorthandProp('icon', Icon, { + mapsValueToProp: 'name', + requiredProps: { name: 'at' }, + }) attachmentImplementsShorthandProp('action', Button) describe('accessibility', () => { diff --git a/packages/react/test/specs/components/Button/Button-test.tsx b/packages/react/test/specs/components/Button/Button-test.tsx index 35cc702dda..e4d7800836 100644 --- a/packages/react/test/specs/components/Button/Button-test.tsx +++ b/packages/react/test/specs/components/Button/Button-test.tsx @@ -17,7 +17,10 @@ const buttonImplementsShorthandProp = implementsShorthandProp(Button) describe('Button', () => { isConformant(Button) - buttonImplementsShorthandProp('icon', Icon, { mapsValueToProp: 'name' }) + buttonImplementsShorthandProp('icon', Icon, { + mapsValueToProp: 'name', + requiredProps: { name: 'at' }, + }) describe('accessibility', () => { describe('button', () => { diff --git a/packages/react/test/specs/components/Icon/Icon-test.tsx b/packages/react/test/specs/components/Icon/Icon-test.tsx index 9c27b2b739..e67250bf56 100644 --- a/packages/react/test/specs/components/Icon/Icon-test.tsx +++ b/packages/react/test/specs/components/Icon/Icon-test.tsx @@ -6,11 +6,14 @@ import { mountWithProviderAndGetComponent } from 'test/utils' import { ThemeInput } from 'src/themes/types' describe('Icon', () => { - isConformant(Icon) + isConformant(Icon, { requiredProps: { name: 'at' } }) describe('accessibility', () => { handlesAccessibility(Icon, { defaultRootRole: 'img', + requiredProps: { + name: 'at', + }, }) describe('aria-hidden', () => { diff --git a/packages/react/test/specs/components/Input/Input-test.tsx b/packages/react/test/specs/components/Input/Input-test.tsx index 65c748d90e..f2307bd384 100644 --- a/packages/react/test/specs/components/Input/Input-test.tsx +++ b/packages/react/test/specs/components/Input/Input-test.tsx @@ -43,7 +43,10 @@ describe('Input', () => { }) implementsShorthandProp(Input)('input', Box, { mapsValueToProp: 'type' }) - implementsShorthandProp(Input)('icon', Icon, { mapsValueToProp: 'name' }) + implementsShorthandProp(Input)('icon', Icon, { + mapsValueToProp: 'name', + requiredProps: { name: 'at' }, + }) describe('wrapper', () => { implementsShorthandProp(Input)('wrapper', Box, { mapsValueToProp: 'children' }) diff --git a/packages/react/test/specs/components/Label/Label-test.tsx b/packages/react/test/specs/components/Label/Label-test.tsx index a6ec7f2ba7..e5a75fb789 100644 --- a/packages/react/test/specs/components/Label/Label-test.tsx +++ b/packages/react/test/specs/components/Label/Label-test.tsx @@ -8,6 +8,9 @@ const labelImplementsShorthandProp = implementsShorthandProp(Label) describe('Label', () => { isConformant(Label) - labelImplementsShorthandProp('icon', Icon, { mapsValueToProp: 'name' }) + labelImplementsShorthandProp('icon', Icon, { + mapsValueToProp: 'name', + requiredProps: { name: 'at' }, + }) labelImplementsShorthandProp('image', Image, { mapsValueToProp: 'src' }) }) From f41849a8ec781fd563dfb4f4f0bac31c0050c841 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Pavel=20Lu=C4=8Div=C5=88=C3=A1k?= Date: Mon, 29 Jul 2019 17:17:40 +0200 Subject: [PATCH 6/6] Fix changelog change --- CHANGELOG.md | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 8fd9da395b..e2779ed10f 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -20,6 +20,8 @@ This project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.htm ### Features - Expose `isFromKeyboard` in `Grid` component @sophieH29 ([#1729](https://github.com/stardust-ui/react/pull/1729)) +### Fixes +- Require `name` prop in `Icon` component @lucivpav ([#1723](https://github.com/stardust-ui/react/pull/1723)) ## [v0.35.0](https://github.com/stardust-ui/react/tree/v0.35.0) (2019-07-26) @@ -57,7 +59,6 @@ This project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.htm - `Loader` uses `Text` component for `label` slot instead of `Box` @layershifter ([#1701](https://github.com/stardust-ui/react/pull/1701)) - Fix test cut off in `Button` component @layershifter ([#1716](https://github.com/stardust-ui/react/pull/1716)) - Close `Toolbar`'s menu when it looses focus @sophieH29 ([#1688](https://github.com/stardust-ui/react/pull/1688)) -- Require `name` prop in `Icon` component @lucivpav ([#1723](https://github.com/stardust-ui/react/pull/1723)) ### Documentation - Make sidebar categories collapsible @lucivpav ([#1611](https://github.com/stardust-ui/react/pull/1611))