@loja-integrada/admin-components 0.9.9 → 0.12.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@loja-integrada/admin-components",
3
- "version": "0.9.9",
3
+ "version": "0.12.1",
4
4
  "author": "Loja Integrada Front-End Team",
5
5
  "license": "MIT",
6
6
  "main": "dist/index.js",
@@ -64,6 +64,9 @@ describe('Button tests', () => {
64
64
 
65
65
  mount(<Default variant="danger" />)
66
66
  cy.get('button').should('have.class', 'bg-danger text-base-1')
67
+
68
+ mount(<Default variant="outlineSecondary" />)
69
+ cy.get('button').should('have.class', 'bg-transparent text-primary border border-primary')
67
70
  })
68
71
 
69
72
  })
@@ -5,6 +5,7 @@ import { Icon, IconProps } from '../../Icons/Icon'
5
5
  const listOfStylesHover = {
6
6
  primary: `hover:bg-primary-dark`,
7
7
  secondary: `hover:bg-secondary-dark`,
8
+ outlineSecondary: `hover:bg-primary-light`,
8
9
  tertiary: `hover:bg-tertiary-dark`,
9
10
  info: `hover:bg-secondary-bold`,
10
11
  warning: `hover:bg-warning-dark`,
@@ -15,6 +16,7 @@ const listOfStylesHover = {
15
16
  const listOfStylesActive = {
16
17
  primary: `active:bg-primary-bold`,
17
18
  secondary: `active:shadow-inner`,
19
+ outlineSecondary: `active:shadow-inner active:bg-base-1`,
18
20
  tertiary: `active:bg-tertiary-bold`,
19
21
  warning: `active:bg-warning-bold`,
20
22
  danger: `hover:bg-danger-bold`,
@@ -24,6 +26,7 @@ const listOfStylesActive = {
24
26
  const listOfStylesFocus = {
25
27
  primary: `focus:ring-1 focus:ring-primary-dark focus:ring-opacity-50`,
26
28
  secondary: `focus:ring focus:ring-focus`,
29
+ outlineSecondary: `focus:ring-2 focus:ring-focus focus:ring-offset-1`,
27
30
  danger: `focus:ring-1 focus:ring-danger-dark`,
28
31
  outline: `focus:ring-2 focus:ring-focus focus:ring-offset-1`,
29
32
  onlyText: `focus:bg-base-1`,
@@ -31,6 +34,7 @@ const listOfStylesFocus = {
31
34
  const listOfStyles = {
32
35
  primary: `bg-primary text-base-1 ${listOfStylesHover['primary']} ${listOfStylesActive['primary']} ${listOfStylesFocus['primary']}`,
33
36
  secondary: `bg-secondary text-primary ${listOfStylesHover['secondary']} ${listOfStylesActive['secondary']}`,
37
+ outlineSecondary: `bg-transparent text-primary border border-primary ${listOfStylesHover['outlineSecondary']} ${listOfStylesActive['outlineSecondary']} ${listOfStylesFocus['outlineSecondary']}`,
34
38
  tertiary: `bg-inverted-2 text-on-primary ${listOfStylesHover['tertiary']} ${listOfStylesActive['tertiary']}`,
35
39
  info: `bg-secondary-dark text-base-1 ${listOfStylesHover['info']}`,
36
40
  warning: `bg-warning text-on-base ${listOfStylesHover['warning']} ${listOfStylesActive['warning']}`,
@@ -43,6 +47,7 @@ const defaultDisabledStyle = `bg-base-3 cursor-default text-on-base-2 shadow-non
43
47
  const listOfStylesDisabled = {
44
48
  primary: defaultDisabledStyle,
45
49
  secondary: `bg-base-2 cursor-default text-card-stroke shadow-none ring-0 border-0 `,
50
+ outlineSecondary: `bg-base-2 cursor-default text-card-stroke shadow-none ring-0 border-0 `,
46
51
  tertiary: defaultDisabledStyle,
47
52
  info: defaultDisabledStyle,
48
53
  warning: defaultDisabledStyle,
@@ -150,6 +155,7 @@ export interface ButtonProps extends ButtonAnchorProps {
150
155
  variant?:
151
156
  | 'primary'
152
157
  | 'secondary'
158
+ | 'outlineSecondary'
153
159
  | 'tertiary'
154
160
  | 'info'
155
161
  | 'warning'
@@ -166,7 +166,7 @@ const CustomSingleValue = (
166
166
  ) => (
167
167
  <SingleValue
168
168
  {...props}
169
- className={`text-f6 tracking-4 text-inverted-2 text-sm truncate ${variantValueClasses[variant]}`}
169
+ className={`text-f6 tracking-4 text-on-base text-sm truncate ${variantValueClasses[variant]}`}
170
170
  />
171
171
  )
172
172
 
@@ -23,8 +23,8 @@ export const formatValuePatterns = {
23
23
  },
24
24
  onlyText: {
25
25
  mask: (rawValue: any) => {
26
- const onlyText = rawValue.replace(/[^a-zA-ZÀ-ú'~0-9\s]/g, '').split('')
27
- return onlyText.map(() => /[a-zA-ZÀ-ú'~´`^0-9\s]/g)
26
+ const onlyText = rawValue.replace(/[^a-zA-ZÀ-ú'˜0-9\]/g, '').split('')
27
+ return onlyText.map(() => /[a-zA-ZÀ-ú'˜`´^0-9\]/g)
28
28
  },
29
29
  },
30
30
  date: {
@@ -7,6 +7,9 @@ const ToggleComponent = (
7
7
  const inputId = id || name
8
8
  const [isChecked, setIsChecked] = React.useState(checked || false)
9
9
 
10
+ const toggleStatusText = disabled ? 'disabled' : 'enabled'
11
+ const toggleCheckText = isChecked ? 'checked' : 'unchecked'
12
+
10
13
  React.useEffect(() => {
11
14
  setIsChecked(!!checked)
12
15
  }, [checked])
@@ -17,18 +20,36 @@ const ToggleComponent = (
17
20
  onChange && onChange(event)
18
21
  }
19
22
 
23
+ const toggleClasses = {
24
+ background: {
25
+ checked: {
26
+ enabled: 'bg-primary border-primary',
27
+ disabled: 'bg-base-3 border-card-stroke',
28
+ },
29
+ unchecked: {
30
+ enabled: 'bg-base-1 border-card-stroke',
31
+ disabled: 'bg-base-3 border-card-stroke',
32
+ },
33
+ },
34
+ circle: {
35
+ checked: {
36
+ enabled: 'translate-x-full ml-px bg-base-1',
37
+ disabled: 'translate-x-full ml-px bg-base-1',
38
+ },
39
+ unchecked: {
40
+ enabled: 'translate-x-0 bg-inverted-2',
41
+ disabled: 'translate-x-0 bg-base-1',
42
+ },
43
+ },
44
+ }
45
+
20
46
  const toggleContainerDisabledClasses = `${
21
47
  disabled ? 'pointer-events-none' : ''
22
48
  } relative`
23
49
 
24
- const toggleBackgroundClasses = `block border border-card-stroke w-[53px] h-8 rounded-full
25
- ${disabled ? ' bg-base-3' : ' bg-base-1'} `
50
+ const toggleBackgroundClasses = `block border w-[53px] h-8 rounded-full ${toggleClasses.background[toggleCheckText][toggleStatusText]} transition`
26
51
 
27
- const toggleCircleClasses = `transform ${
28
- !isChecked
29
- ? 'translate-x-0 bg-inverted-2'
30
- : 'translate-x-full ml-px ' + (disabled ? 'bg-base-1' : 'bg-primary')
31
- } absolute left-[6px] top-[6px] w-5 h-5 rounded-full transition`
52
+ const toggleCircleClasses = `transform ${toggleClasses.circle[toggleCheckText][toggleStatusText]} absolute left-[6px] top-[6px] w-5 h-5 rounded-full transition`
32
53
 
33
54
  const toggleLabelClasses = `ml-2 text-inverted-1 text-f6 tracking-4 label`
34
55
 
@@ -55,8 +76,8 @@ const ToggleComponent = (
55
76
  )
56
77
  }
57
78
 
58
- const ToggleWithFowardRef = React.forwardRef(ToggleComponent)
59
- export const Toggle = React.memo(ToggleWithFowardRef)
79
+ const ToggleWithForwardRef = React.forwardRef(ToggleComponent)
80
+ export const Toggle = React.memo(ToggleWithForwardRef)
60
81
 
61
82
  export interface ToggleProps
62
83
  extends React.InputHTMLAttributes<HTMLInputElement> {
@@ -0,0 +1,9 @@
1
+ import React from 'react'
2
+
3
+ export const Download = () => (
4
+ <path
5
+ fillRule="evenodd"
6
+ d="M14.667 11.556v2.666c0 .246-.2.445-.445.445H1.778a.445.445 0 0 1-.445-.445v-2.666H0v2.666C0 15.204.796 16 1.778 16h12.444c.982 0 1.778-.796 1.778-1.778v-2.666h-1.333ZM3.109 7.607a.668.668 0 0 1 .893-.992l3.331 3V0h1.334v9.614l3.331-2.999a.668.668 0 0 1 .893.992l-4.445 4a.667.667 0 0 1-.892 0l-4.445-4Z"
7
+ clipRule="evenodd"
8
+ />
9
+ )
@@ -0,0 +1,9 @@
1
+ import React from 'react'
2
+
3
+ export const ExclamationCircle = () => (
4
+ <path
5
+ fillRule="evenodd"
6
+ d="M9 10.5A1.25 1.25 0 1 0 9 13a1.25 1.25 0 0 0 0-2.5Zm-.303-1h.605a.5.5 0 0 0 .497-.445l.328-2.945A1 1 0 0 0 9.132 5h-.266a1 1 0 0 0-.993 1.11L8.2 9.055a.5.5 0 0 0 .497.445Zm.303 7c-4.136 0-7.5-3.364-7.5-7.5S4.864 1.5 9 1.5s7.5 3.364 7.5 7.5-3.364 7.5-7.5 7.5ZM9 0a9 9 0 0 0-9 9 9 9 0 0 0 9 9 9 9 0 0 0 9-9 9 9 0 0 0-9-9Z"
7
+ clipRule="evenodd"
8
+ />
9
+ )
@@ -16,10 +16,12 @@ import { Close } from './Close'
16
16
  import { Check } from './Check'
17
17
  import { CheckCircle } from './CheckCircle'
18
18
  import { CreditCard } from './CreditCard'
19
+ import { Download } from './Download'
19
20
  import { Product } from './Product'
20
21
  import { Edit } from './Edit'
21
22
  import { Exchange } from './Exchange'
22
23
  import { Eye } from './Eye'
24
+ import { ExclamationCircle } from './ExclamationCircle'
23
25
  import { ExclamationTriangle } from './ExclamationTriangle'
24
26
  import { ExternalLink } from './ExternalLink'
25
27
  import { Home } from './Home'
@@ -70,10 +72,12 @@ export const icons = {
70
72
  close: Close,
71
73
  checkCircle: CheckCircle,
72
74
  creditcard: CreditCard,
75
+ download: Download,
73
76
  product: Product,
74
77
  edit: Edit,
75
78
  exchange: Exchange,
76
79
  eye: Eye,
80
+ exclamationCircle: ExclamationCircle,
77
81
  exclamationTriangle: ExclamationTriangle,
78
82
  externalLink: ExternalLink,
79
83
  home: Home,
@@ -21,7 +21,7 @@ export default {
21
21
  } as Meta
22
22
 
23
23
  const Template: Story<TooltipProps> = args => (
24
- <div className="my-10 flex justify-center">
24
+ <div className="absolute bg-base-2 inset-0 flex items-center justify-center">
25
25
  <Tooltip {...args}>
26
26
  <a href="#">
27
27
  <Icon icon="eye" />
@@ -26,7 +26,7 @@ const TooltipComponent = (props: TooltipProps) => {
26
26
  }
27
27
 
28
28
  return (
29
- <Tippy
29
+ <StyledTooltipComponent
30
30
  {...computedProps}
31
31
  appendTo={props?.appendTo || 'parent'}
32
32
  hideOnClick={props?.hideOnClick || false}
@@ -35,15 +35,29 @@ const TooltipComponent = (props: TooltipProps) => {
35
35
  duration={props?.duration || 150}
36
36
  placement={window?.innerWidth < 1024 ? 'top' : props?.placement || 'top'}
37
37
  interactive={props?.interactive || false}
38
+ theme={props?.theme || 'dark'}
38
39
  />
39
40
  )
40
41
  }
41
42
 
42
- const styledTooltipComponent = styled(TooltipComponent)`
43
- --bg-color: #20221b;
43
+ const theme: Record<string, Record<string, string>> = {
44
+ light: {
45
+ background: '#fff',
46
+ color: '#371E56',
47
+ },
48
+ dark: {
49
+ background: '#371E56',
50
+ color: '#fff',
51
+ },
52
+ }
53
+
54
+ const StyledTooltipComponent = styled(Tippy)<{
55
+ theme: string
56
+ }>`
57
+ --bg-color: ${(props) => theme[props.theme].background};
44
58
  position: relative;
45
59
  background-color: var(--bg-color);
46
- color: #fff;
60
+ color: ${(props) => theme[props.theme].color};
47
61
  border-radius: 3px;
48
62
  font-size: 12px;
49
63
  letter-spacing: -0.4px;
@@ -129,7 +143,7 @@ const styledTooltipComponent = styled(TooltipComponent)`
129
143
  }
130
144
  `
131
145
 
132
- export const Tooltip = React.memo(styledTooltipComponent)
146
+ export const Tooltip = React.memo(TooltipComponent)
133
147
 
134
148
  export interface TooltipProps extends TippyProps {
135
149
  /** Tooltip append
@@ -160,4 +174,8 @@ export interface TooltipProps extends TippyProps {
160
174
  * @default false
161
175
  * */
162
176
  interactive?: TippyProps['interactive']
177
+ /** Tooltip theme
178
+ * @default dark
179
+ * */
180
+ theme?: 'light' | 'dark'
163
181
  }