@loja-integrada/admin-components 0.19.3 → 0.19.5

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.19.3",
3
+ "version": "0.19.5",
4
4
  "author": "Loja Integrada Front-End Team",
5
5
  "license": "MIT",
6
6
  "repository": {
@@ -35,4 +35,11 @@ describe(specTitle('Tabs tests'), () => {
35
35
  .get('span').contains('Cupons de desconto')
36
36
  })
37
37
 
38
+ it('Title complement', () => {
39
+ mount(<Default />)
40
+ cy.get('.tabs .tabs-item').eq(2).within(() => {
41
+ cy.get('span').contains('Todos os relatórios da loja')
42
+ cy.get('span').contains('NOVO')
43
+ })
44
+ })
38
45
  })
@@ -3,6 +3,7 @@ import { Story, Meta } from '@storybook/react'
3
3
  import { withDesign } from 'storybook-addon-designs'
4
4
 
5
5
  import { Tabs, TabsProps } from './Tabs'
6
+ import { Badge } from '../../Indicators'
6
7
 
7
8
  export default {
8
9
  title: 'Components/Tabs',
@@ -32,7 +33,13 @@ export default {
32
33
  },
33
34
  {
34
35
  id: 'relatorios',
35
- title: 'Todos os relatorio da loja',
36
+ title: 'Todos os relatórios da loja',
37
+ titleComplement: (
38
+ <Badge
39
+ text="NOVO"
40
+ type="primary"
41
+ />
42
+ ),
36
43
  },
37
44
  {
38
45
  id: 'vendas',
@@ -7,6 +7,10 @@ export interface TabsItemInterface {
7
7
  * Item visible title
8
8
  */
9
9
  title: string
10
+ /**
11
+ * Complement to title
12
+ * */
13
+ titleComplement?: string | React.ReactNode
10
14
  /**
11
15
  * Disabled a specific tab
12
16
  */
@@ -21,6 +21,7 @@ interface TabsItemProps extends TabsItemInterface {
21
21
  export const TabsItem = ({
22
22
  id,
23
23
  title,
24
+ titleComplement,
24
25
  active = false,
25
26
  disabled = false,
26
27
  onChange,
@@ -44,6 +45,7 @@ export const TabsItem = ({
44
45
  data-title={title}
45
46
  >
46
47
  {title}
48
+ {titleComplement && <span className="ml-2">{titleComplement}</span>}
47
49
  </span>
48
50
  </button>
49
51
  )
@@ -33,4 +33,10 @@ describe(specTitle('InformationBox tests'), () => {
33
33
  cy.get('.InformationBox-icon').should('have.class', 'icon-lightbulb')
34
34
  cy.get('.InformationBox').should('have.class', 'bg-focus-light')
35
35
  })
36
+
37
+ it('Close button', () => {
38
+ mount(<Default showClose={true} />)
39
+ cy.get('.InformationBox-close').click()
40
+ cy.get('.InformationBox').should('not.exist')
41
+ })
36
42
  })
@@ -1,4 +1,4 @@
1
- import React from 'react'
1
+ import React, { useState } from 'react'
2
2
  import { Icon, IconProps } from '../../Icons'
3
3
 
4
4
  type InformationBoxTypesOptions = 'success' | 'warning' | 'danger' | 'info'
@@ -45,9 +45,20 @@ const InformationBoxTypes: Record<
45
45
 
46
46
  const InformationBoxComponent = ({
47
47
  type = 'info',
48
- subtitle,
49
48
  title,
49
+ subtitle,
50
+ showClose = false,
51
+ onClose,
50
52
  }: InformationBoxProps) => {
53
+ const [isInformationBoxOpen, setIsInformationBoxOpen] = useState(true)
54
+
55
+ const handleOnClose = () => {
56
+ setIsInformationBoxOpen(false)
57
+ onClose?.()
58
+ }
59
+
60
+ if (!isInformationBoxOpen) return null
61
+
51
62
  return (
52
63
  <div
53
64
  className={`InformationBox pl-4 pr-6 pt-5 pb-6 rounded w-full relative flex items-start mb-3 ${InformationBoxTypes[type].class}`}
@@ -65,7 +76,7 @@ const InformationBoxComponent = ({
65
76
  <div className="flex-grow flex flex-col sm:flex-row items-start justify-between min-w-0">
66
77
  <div className="flex flex-col justify-center min-w-0 break-words tracking-4 leading-6 text-on-base">
67
78
  <span
68
- className={`InformationBox-title text-f5 font-bold ${InformationBoxTypes[type].titleClass}`}
79
+ className={`InformationBox-title text-f5 font-semibold ${InformationBoxTypes[type].titleClass}`}
69
80
  >
70
81
  {title || InformationBoxTypes[type].title}
71
82
  </span>
@@ -76,6 +87,15 @@ const InformationBoxComponent = ({
76
87
  )}
77
88
  </div>
78
89
  </div>
90
+
91
+ {(showClose || onClose) && (
92
+ <button
93
+ className="InformationBox-close absolute top-4 right-4 text-on-base-2"
94
+ onClick={handleOnClose}
95
+ >
96
+ <Icon icon="close" size={4} />
97
+ </button>
98
+ )}
79
99
  </div>
80
100
  )
81
101
  }
@@ -95,4 +115,12 @@ export interface InformationBoxProps {
95
115
  * InformationBox text below title
96
116
  */
97
117
  subtitle?: string | React.ReactNode
118
+ /** Show close button
119
+ * @default false
120
+ */
121
+ showClose?: boolean
122
+ /**
123
+ * Function to close InformationBox (also activate `showClose`)
124
+ */
125
+ onClose?: () => void
98
126
  }