@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.
- package/dist/Button/Button.d.ts +3 -0
- package/dist/Button/Button.types.d.ts +2 -0
- package/dist/Button/ButtonLoader.d.ts +2 -0
- package/dist/Button/index.d.ts +2 -3
- package/dist/SvgSymbol/SvgSymbol.types.d.ts +1 -1
- package/dist/SvgSymbol/icons.d.ts +5 -0
- package/dist/Toolbar/Toolbar.d.ts +3 -0
- package/dist/Toolbar/Toolbar.types.d.ts +3 -0
- package/dist/Toolbar/ToolbarItem.d.ts +3 -0
- package/dist/Toolbar/index.d.ts +2 -3
- package/dist/ToolbarButton/ToolbarButton.types.d.ts +4 -5
- package/dist/Tooltip/Tooltip.d.ts +3 -0
- package/dist/Tooltip/Tooltip.stories.d.ts +10 -0
- package/dist/Tooltip/Tooltip.types.d.ts +8 -0
- package/dist/Tooltip/TooltipFooter.d.ts +3 -0
- package/dist/Tooltip/index.d.ts +2 -0
- package/dist/constants.d.ts +2 -0
- package/dist/index.d.ts +1 -0
- package/dist/ui-kit-2.cjs.development.js +203 -162
- package/dist/ui-kit-2.cjs.development.js.map +1 -1
- package/dist/ui-kit-2.cjs.production.min.js +1 -1
- package/dist/ui-kit-2.cjs.production.min.js.map +1 -1
- package/dist/ui-kit-2.esm.js +200 -163
- package/dist/ui-kit-2.esm.js.map +1 -1
- package/dist/ui-kit.css +3282 -3193
- package/dist/utils/capitalizeFirstLetter.d.ts +1 -0
- package/package.json +1 -1
- package/src/BookmarkButton/BookmarkButton.css +0 -4
- package/src/BookmarkButton/BookmarkButton.module.css +0 -4
- package/src/Button/Button.module.css +13 -0
- package/src/Button/Button.stories.tsx +15 -1
- package/src/Button/Button.tsx +50 -0
- package/src/Button/Button.types.ts +3 -0
- package/src/Button/{loader.tsx → ButtonLoader.tsx} +1 -3
- package/src/Button/index.tsx +2 -48
- package/src/Cover/Cover.module.css +6 -1
- package/src/EmbedBlock/EmbedBlock.test.tsx +2 -6
- package/src/SvgSymbol/SvgSymbol.module.css +4 -0
- package/src/SvgSymbol/SvgSymbol.stories.tsx +1 -1
- package/src/SvgSymbol/SvgSymbol.types.ts +1 -0
- package/src/SvgSymbol/icons.ts +6 -0
- package/src/Toolbar/Toolbar.module.css +0 -5
- package/src/Toolbar/Toolbar.stories.tsx +17 -16
- package/src/Toolbar/Toolbar.tsx +20 -0
- package/src/Toolbar/Toolbar.types.ts +4 -0
- package/src/Toolbar/ToolbarItem.tsx +8 -0
- package/src/Toolbar/index.tsx +2 -20
- package/src/ToolbarButton/ToolbarButton.module.css +0 -14
- package/src/ToolbarButton/ToolbarButton.types.ts +4 -5
- package/src/ToolbarButton/index.tsx +14 -23
- package/src/Tooltip/Tooltip.module.css +91 -0
- package/src/Tooltip/Tooltip.stories.module.css +7 -0
- package/src/Tooltip/Tooltip.stories.tsx +69 -0
- package/src/Tooltip/Tooltip.test.tsx +16 -0
- package/src/Tooltip/Tooltip.tsx +24 -0
- package/src/Tooltip/Tooltip.types.ts +8 -0
- package/src/Tooltip/TooltipFooter.tsx +7 -0
- package/src/Tooltip/index.tsx +2 -0
- package/src/constants.ts +2 -0
- package/src/index.tsx +1 -0
- package/src/utils/capitalizeFirstLetter.ts +2 -0
- 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,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
|
+
}
|
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
package/dist/Button/loader.d.ts
DELETED