From ba5def9b760798c28576f13cf3a83ca04a3dee8f Mon Sep 17 00:00:00 2001 From: Brett Dorrans Date: Sun, 28 Aug 2022 02:47:21 +0100 Subject: [PATCH] feat: improve Tag styles (#1171) * feat: improve Tag styles * feat: improve Tag styles * feat: improve Tag styles --- .../button-group/ButtonGroup.spec.tsx | 70 ---- .../button-group/ButtonGroup.stories.tsx | 32 -- .../__snapshots__/ButtonGroup.spec.tsx.snap | 350 ------------------ src/components/button-group/index.tsx | 36 -- src/components/button-group/styles.ts | 12 - .../button/__snapshots__/Button.spec.tsx.snap | 4 +- src/components/index.ts | 1 - .../tag/__snapshots__/Tag.spec.tsx.snap | 8 +- src/components/tag/styles.ts | 1 + src/components/theme-provider/defaultTheme.ts | 2 +- 10 files changed, 8 insertions(+), 508 deletions(-) delete mode 100644 src/components/button-group/ButtonGroup.spec.tsx delete mode 100644 src/components/button-group/ButtonGroup.stories.tsx delete mode 100644 src/components/button-group/__snapshots__/ButtonGroup.spec.tsx.snap delete mode 100644 src/components/button-group/index.tsx delete mode 100644 src/components/button-group/styles.ts diff --git a/src/components/button-group/ButtonGroup.spec.tsx b/src/components/button-group/ButtonGroup.spec.tsx deleted file mode 100644 index 8040471c..00000000 --- a/src/components/button-group/ButtonGroup.spec.tsx +++ /dev/null @@ -1,70 +0,0 @@ -import * as React from 'react'; -import { render } from '@testing-library/react'; -import '@testing-library/jest-dom'; -import 'jest-styled-components'; - -import { ThemeProvider } from '../theme-provider'; -import { Button } from '../button'; -import { - ButtonGroup, - ButtonGroupChildrenType, - ButtonGroupPropType -} from './index'; - -const sameButtons = [ - , - , - -]; - -const differentButtons = [ - , - , - -]; - -const twoButtons = [ - , - -]; - -const setup = ( - props?: ButtonGroupPropType, - children: ButtonGroupChildrenType = sameButtons -) => - render( - - {children} - - ); - -test('it works with same buttons', () => { - const { container } = setup(); - expect(container.firstChild).toMatchSnapshot(); -}); - -test('it works with different buttons', () => { - const { container } = setup({}, differentButtons); - expect(container.firstChild).toMatchSnapshot(); -}); - -test('it works with two buttons', () => { - const { container } = setup({}, twoButtons); - expect(container.firstChild).toMatchSnapshot(); -}); diff --git a/src/components/button-group/ButtonGroup.stories.tsx b/src/components/button-group/ButtonGroup.stories.tsx deleted file mode 100644 index 9ff0f115..00000000 --- a/src/components/button-group/ButtonGroup.stories.tsx +++ /dev/null @@ -1,32 +0,0 @@ -import * as React from 'react'; -import { ThemeProvider } from '../theme-provider'; -import { ButtonGroup } from './index'; -import { Button } from '../button'; - -export default { - title: 'Components/ButtonGroup', - component: ButtonGroup, - decorators: [(getStory) => {getStory()}], - subcomponents: { Button } -}; - -const templateStyles = {}; - -const DefaultTemplate = (args) => ( - - - - - -); - -export const Default = DefaultTemplate.bind({}); -Default.args = { - styles: templateStyles -}; diff --git a/src/components/button-group/__snapshots__/ButtonGroup.spec.tsx.snap b/src/components/button-group/__snapshots__/ButtonGroup.spec.tsx.snap deleted file mode 100644 index 410e4ae8..00000000 --- a/src/components/button-group/__snapshots__/ButtonGroup.spec.tsx.snap +++ /dev/null @@ -1,350 +0,0 @@ -// Jest Snapshot v1, https://goo.gl/fbAQLP - -exports[`it works with different buttons 1`] = ` -.c0 > :nth-child(n) { - border-radius: 0; -} - -.c0 > :not(:last-child):nth-child(n) { - margin-right: 0.5rem; -} - -.c1 { - border-style: solid; - text-align: center; - position: relative; - font-size: 1rem; - font-weight: 400; - font-family: Montserrat,sans-serif; - line-height: 2; - border-radius: 0.3rem; - border-width: 1px; - box-shadow: 0 1px 3px 0 rgba(0,0,0,0.1),0 1px 2px 0 rgba(0,0,0,0.06); - padding-left: 1rem; - padding-right: 1rem; - padding-top: 0.5rem; - padding-bottom: 0.5rem; - background-color: #17a3a5; - color: white; - border-color: #1a8385; -} - -.c1:hover { - cursor: pointer; - background-color: #1a8385; - color: white; -} - -.c1:hover:disabled { - cursor: not-allowed; - background-color: #1a8385; -} - -.c1:disabled { - opacity: 0.7; - background-color: #1a8385; - color: white; -} - -.c2 { - opacity: 1; - display: -webkit-box; - display: -webkit-flex; - display: -ms-flexbox; - display: flex; - -webkit-align-items: center; - -webkit-box-align: center; - -ms-flex-align: center; - align-items: center; -} - -.c3 { - border-style: solid; - text-align: center; - position: relative; - font-size: 1rem; - font-weight: 400; - font-family: Montserrat,sans-serif; - line-height: 2; - border-radius: 0.3rem; - border-width: 1px; - box-shadow: 0 1px 3px 0 rgba(0,0,0,0.1),0 1px 2px 0 rgba(0,0,0,0.06); - padding-left: 1rem; - padding-right: 1rem; - padding-top: 0.5rem; - padding-bottom: 0.5rem; - background-color: #ebc764; - color: white; - border-color: #937032; -} - -.c3:hover { - cursor: pointer; - background-color: #937032; - color: white; -} - -.c3:hover:disabled { - cursor: not-allowed; - background-color: #937032; -} - -.c3:disabled { - opacity: 0.7; - background-color: #937032; - color: white; -} - -.c4 { - border-style: solid; - text-align: center; - position: relative; - font-size: 1rem; - font-weight: 400; - font-family: Montserrat,sans-serif; - line-height: 2; - border-radius: 0.3rem; - border-width: 1px; - box-shadow: 0 1px 3px 0 rgba(0,0,0,0.1),0 1px 2px 0 rgba(0,0,0,0.06); - padding-left: 1rem; - padding-right: 1rem; - padding-top: 0.5rem; - padding-bottom: 0.5rem; - background-color: #72af5d; - color: white; - border-color: #548230; -} - -.c4:hover { - cursor: pointer; - background-color: #548230; - color: white; -} - -.c4:hover:disabled { - cursor: not-allowed; - background-color: #548230; -} - -.c4:disabled { - opacity: 0.7; - background-color: #548230; - color: white; -} - -
- - - -
-`; - -exports[`it works with same buttons 1`] = ` -.c0 > :nth-child(n) { - border-radius: 0; -} - -.c0 > :not(:last-child):nth-child(n) { - margin-right: 0.5rem; -} - -.c1 { - border-style: solid; - text-align: center; - position: relative; - font-size: 1rem; - font-weight: 400; - font-family: Montserrat,sans-serif; - line-height: 2; - border-radius: 0.3rem; - border-width: 1px; - box-shadow: 0 1px 3px 0 rgba(0,0,0,0.1),0 1px 2px 0 rgba(0,0,0,0.06); - padding-left: 1rem; - padding-right: 1rem; - padding-top: 0.5rem; - padding-bottom: 0.5rem; - background-color: #17a3a5; - color: white; - border-color: #1a8385; -} - -.c1:hover { - cursor: pointer; - background-color: #1a8385; - color: white; -} - -.c1:hover:disabled { - cursor: not-allowed; - background-color: #1a8385; -} - -.c1:disabled { - opacity: 0.7; - background-color: #1a8385; - color: white; -} - -.c2 { - opacity: 1; - display: -webkit-box; - display: -webkit-flex; - display: -ms-flexbox; - display: flex; - -webkit-align-items: center; - -webkit-box-align: center; - -ms-flex-align: center; - align-items: center; -} - -
- - - -
-`; - -exports[`it works with two buttons 1`] = ` -.c0 > :nth-child(n) { - border-radius: 0; -} - -.c0 > :not(:last-child):nth-child(n) { - margin-right: 0.5rem; -} - -.c1 { - border-style: solid; - text-align: center; - position: relative; - font-size: 1rem; - font-weight: 400; - font-family: Montserrat,sans-serif; - line-height: 2; - border-radius: 0.3rem; - border-width: 1px; - box-shadow: 0 1px 3px 0 rgba(0,0,0,0.1),0 1px 2px 0 rgba(0,0,0,0.06); - padding-left: 1rem; - padding-right: 1rem; - padding-top: 0.5rem; - padding-bottom: 0.5rem; - background-color: #17a3a5; - color: white; - border-color: #1a8385; -} - -.c1:hover { - cursor: pointer; - background-color: #1a8385; - color: white; -} - -.c1:hover:disabled { - cursor: not-allowed; - background-color: #1a8385; -} - -.c1:disabled { - opacity: 0.7; - background-color: #1a8385; - color: white; -} - -.c2 { - opacity: 1; - display: -webkit-box; - display: -webkit-flex; - display: -ms-flexbox; - display: flex; - -webkit-align-items: center; - -webkit-box-align: center; - -ms-flex-align: center; - align-items: center; -} - -
- - -
-`; diff --git a/src/components/button-group/index.tsx b/src/components/button-group/index.tsx deleted file mode 100644 index 4c89ae25..00000000 --- a/src/components/button-group/index.tsx +++ /dev/null @@ -1,36 +0,0 @@ -import * as React from 'react'; -import { mergeStyles } from '@lapidist/styles'; -import { Box, BoxProps } from '../box'; -import { Button, ButtonProps } from '../button'; -import { buttonGroupStyles } from './styles'; - -export * from './styles'; - -export type ButtonGroupPropType = BoxProps; - -export type ButtonGroupChildrenType = React.ReactElement[]; - -export interface ButtonGroupProps { - readonly children: ButtonGroupChildrenType; -} - -export const ButtonGroup: React.FC = ({ - as = 'div', - styles, - children, - ...restProps -}) => ( - - {children.map( - ({ props }, index) => - props &&