@meduza/ui-kit-2 0.2.37 → 0.3.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.
Files changed (62) hide show
  1. package/dist/Button/Button.d.ts +3 -0
  2. package/dist/Button/Button.types.d.ts +2 -0
  3. package/dist/Button/ButtonLoader.d.ts +2 -0
  4. package/dist/Button/index.d.ts +2 -3
  5. package/dist/SvgSymbol/SvgSymbol.types.d.ts +1 -1
  6. package/dist/SvgSymbol/icons.d.ts +5 -0
  7. package/dist/Toolbar/Toolbar.d.ts +3 -0
  8. package/dist/Toolbar/Toolbar.types.d.ts +3 -0
  9. package/dist/Toolbar/ToolbarItem.d.ts +3 -0
  10. package/dist/Toolbar/index.d.ts +2 -3
  11. package/dist/ToolbarButton/ToolbarButton.types.d.ts +4 -5
  12. package/dist/Tooltip/Tooltip.d.ts +3 -0
  13. package/dist/Tooltip/Tooltip.stories.d.ts +10 -0
  14. package/dist/Tooltip/Tooltip.types.d.ts +8 -0
  15. package/dist/Tooltip/TooltipFooter.d.ts +3 -0
  16. package/dist/Tooltip/index.d.ts +2 -0
  17. package/dist/constants.d.ts +2 -0
  18. package/dist/index.d.ts +1 -0
  19. package/dist/ui-kit-2.cjs.development.js +203 -162
  20. package/dist/ui-kit-2.cjs.development.js.map +1 -1
  21. package/dist/ui-kit-2.cjs.production.min.js +1 -1
  22. package/dist/ui-kit-2.cjs.production.min.js.map +1 -1
  23. package/dist/ui-kit-2.esm.js +200 -163
  24. package/dist/ui-kit-2.esm.js.map +1 -1
  25. package/dist/ui-kit.css +3282 -3193
  26. package/dist/utils/capitalizeFirstLetter.d.ts +1 -0
  27. package/package.json +1 -1
  28. package/src/BookmarkButton/BookmarkButton.css +0 -4
  29. package/src/BookmarkButton/BookmarkButton.module.css +0 -4
  30. package/src/Button/Button.module.css +13 -0
  31. package/src/Button/Button.stories.tsx +15 -1
  32. package/src/Button/Button.tsx +50 -0
  33. package/src/Button/Button.types.ts +3 -0
  34. package/src/Button/{loader.tsx → ButtonLoader.tsx} +1 -3
  35. package/src/Button/index.tsx +2 -48
  36. package/src/Cover/Cover.module.css +6 -1
  37. package/src/EmbedBlock/EmbedBlock.test.tsx +2 -6
  38. package/src/SvgSymbol/SvgSymbol.module.css +4 -0
  39. package/src/SvgSymbol/SvgSymbol.stories.tsx +1 -1
  40. package/src/SvgSymbol/SvgSymbol.types.ts +1 -0
  41. package/src/SvgSymbol/icons.ts +6 -0
  42. package/src/Toolbar/Toolbar.module.css +0 -5
  43. package/src/Toolbar/Toolbar.stories.tsx +17 -16
  44. package/src/Toolbar/Toolbar.tsx +20 -0
  45. package/src/Toolbar/Toolbar.types.ts +4 -0
  46. package/src/Toolbar/ToolbarItem.tsx +8 -0
  47. package/src/Toolbar/index.tsx +2 -20
  48. package/src/ToolbarButton/ToolbarButton.module.css +0 -14
  49. package/src/ToolbarButton/ToolbarButton.types.ts +4 -5
  50. package/src/ToolbarButton/index.tsx +14 -23
  51. package/src/Tooltip/Tooltip.module.css +91 -0
  52. package/src/Tooltip/Tooltip.stories.module.css +7 -0
  53. package/src/Tooltip/Tooltip.stories.tsx +69 -0
  54. package/src/Tooltip/Tooltip.test.tsx +16 -0
  55. package/src/Tooltip/Tooltip.tsx +24 -0
  56. package/src/Tooltip/Tooltip.types.ts +8 -0
  57. package/src/Tooltip/TooltipFooter.tsx +7 -0
  58. package/src/Tooltip/index.tsx +2 -0
  59. package/src/constants.ts +2 -0
  60. package/src/index.tsx +1 -0
  61. package/src/utils/capitalizeFirstLetter.ts +2 -0
  62. package/dist/Button/loader.d.ts +0 -3
@@ -0,0 +1,69 @@
1
+ import React, { useState } from 'react'
2
+ import { Tooltip } from './'
3
+ import { PreviewWrapper } from '../_storybook/PreviewWrapper'
4
+
5
+ import styles from './Tooltip.stories.module.css'
6
+
7
+ export default {
8
+ title: 'Main / Tooltip',
9
+ component: Tooltip,
10
+ parameters: {
11
+ themeWrapperSideBySide: true
12
+ }
13
+ }
14
+
15
+ const Example: React.FC = () => {
16
+ const [x, setX] = useState<'left' | 'center'>('left')
17
+ const [y, setY] = useState<'top' | 'bottom'>('top')
18
+
19
+ const handleX = () => {
20
+ setX(x === 'left' ? 'center' : 'left')
21
+ }
22
+
23
+ const handleY = () => {
24
+ setY(y === 'top' ? 'bottom' : 'top')
25
+ }
26
+
27
+ return (
28
+ <>
29
+ <div className={styles.root}>
30
+ <button type="button" onClick={() => handleX()}>
31
+ {x === 'left' ? 'center' : 'left'}
32
+ </button>
33
+
34
+ <button type="button" onClick={() => handleY()}>
35
+ {y === 'bottom' ? 'top' : 'bottom'}
36
+ </button>
37
+
38
+ <div style={{ marginTop: 100 }}>
39
+ <Tooltip position={[x, y]}>
40
+ <h3>Magic link!</h3>
41
+ <p>
42
+ Это магическая ссылка: она открывает лайт-версию материала. Ее
43
+ можно отправить тому, у кого «Медуза» заблокирована — и все
44
+ откроется!
45
+ </p>
46
+ <p>
47
+ <a href="https://meduza.io" target="_blank" rel="noreferrer">
48
+ Будьте осторожны
49
+ </a>{' '}
50
+ «Медуза» в РФ — «нежелательная» организация. Не посылайте наши
51
+ статьи людям, которым вы не доверяете.
52
+ </p>
53
+ </Tooltip>
54
+ </div>
55
+ </div>
56
+ </>
57
+ )
58
+ }
59
+
60
+ export const Default: React.FC = () => (
61
+ <>
62
+ <PreviewWrapper theme="light">
63
+ <Example />
64
+ </PreviewWrapper>
65
+ <PreviewWrapper theme="dark">
66
+ <Example />
67
+ </PreviewWrapper>
68
+ </>
69
+ )
@@ -0,0 +1,16 @@
1
+ import React from 'react'
2
+ import { render } from '@testing-library/react'
3
+ import { Tooltip } from './'
4
+ import { TooltipProps } from './Tooltip.types'
5
+
6
+ describe('Tooltip', () => {
7
+ let props: TooltipProps
8
+
9
+ const renderComponent = () => render(<Tooltip {...props} />)
10
+
11
+ it('should have root style', () => {
12
+ const { container } = renderComponent()
13
+
14
+ expect(container).toBeInTheDocument()
15
+ })
16
+ })
@@ -0,0 +1,24 @@
1
+ import React from 'react'
2
+ import { TooltipProps } from './Tooltip.types'
3
+ import { makeClassName } from '../utils/makeClassName'
4
+ import styles from './Tooltip.module.css'
5
+ import { capitalizeFirstLetter } from '../utils/capitalizeFirstLetter'
6
+
7
+ export const Tooltip: React.FC<TooltipProps> = ({ children, position }) => {
8
+ const [x, y] = position
9
+
10
+ const positionClass = `is${capitalizeFirstLetter(x)}${capitalizeFirstLetter(
11
+ y
12
+ )}`
13
+
14
+ return (
15
+ <div
16
+ className={makeClassName([
17
+ [styles.root, true],
18
+ [styles[positionClass], true]
19
+ ])}
20
+ >
21
+ <div className={styles.body}>{children}</div>
22
+ </div>
23
+ )
24
+ }
@@ -0,0 +1,8 @@
1
+ export interface TooltipProps {
2
+ children: React.ReactNode
3
+ position: ['left' | 'center', 'top' | 'bottom']
4
+ }
5
+
6
+ export interface TooltipFooterProps {
7
+ children: React.ReactNode
8
+ }
@@ -0,0 +1,7 @@
1
+ import React from 'react'
2
+ import { TooltipFooterProps } from './Tooltip.types'
3
+ import styles from './Tooltip.module.css'
4
+
5
+ export const TooltipFooter: React.FC<TooltipFooterProps> = ({ children }) => {
6
+ return <div className={styles.footer}>{children}</div>
7
+ }
@@ -0,0 +1,2 @@
1
+ export { Tooltip } from './Tooltip'
2
+ export { TooltipFooter } from './TooltipFooter'
package/src/constants.ts CHANGED
@@ -29,6 +29,7 @@ export const SocialLabels = {
29
29
  fb: 'Фейсбук',
30
30
  tw: 'Твиттер',
31
31
  pdf: 'PDF',
32
+ unblock: 'Magic link',
32
33
  bookmark: 'В закладки',
33
34
  reaction: 'Напишите нам'
34
35
  },
@@ -37,6 +38,7 @@ export const SocialLabels = {
37
38
  fb: 'Fb',
38
39
  tw: 'Twitter',
39
40
  pdf: 'PDF',
41
+ unblock: 'Magic link',
40
42
  bookmark: 'Add to bookmarks'
41
43
  }
42
44
  }
package/src/index.tsx CHANGED
@@ -42,4 +42,5 @@ export * from './SensitiveBlock'
42
42
  export * from './DonatesTeaser'
43
43
  export * from './ShopRelatedBlock'
44
44
  export * from './AnnouncementInText'
45
+ export * from './Tooltip'
45
46
  // /* PLOP_INJECT_LINK */ //
@@ -0,0 +1,2 @@
1
+ export const capitalizeFirstLetter = (string: string): string =>
2
+ string.charAt(0).toUpperCase() + string.slice(1)
@@ -1,3 +0,0 @@
1
- import React from 'react';
2
- declare const Loader: React.FC;
3
- export default Loader;