@channel.io/bezier-react 2.0.5 → 2.0.6
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/cjs/components/AlphaButton/Button.js +18 -10
- package/dist/cjs/components/AlphaButton/Button.js.map +1 -1
- package/dist/cjs/components/AlphaFloatingButton/FloatingButton.js +18 -9
- package/dist/cjs/components/AlphaFloatingButton/FloatingButton.js.map +1 -1
- package/dist/cjs/components/AlphaFloatingIconButton/FloatingIconButton.js +57 -0
- package/dist/cjs/components/AlphaFloatingIconButton/FloatingIconButton.js.map +1 -0
- package/dist/cjs/components/AlphaFloatingIconButton/FloatingIconButton.module.scss.js +8 -0
- package/dist/cjs/components/AlphaFloatingIconButton/FloatingIconButton.module.scss.js.map +1 -0
- package/dist/cjs/components/AlphaIconButton/IconButton.js +5 -5
- package/dist/cjs/components/AlphaIconButton/IconButton.js.map +1 -1
- package/dist/cjs/index.js +2 -0
- package/dist/cjs/index.js.map +1 -1
- package/dist/cjs/styles.css +1 -1
- package/dist/esm/components/AlphaButton/Button.mjs +18 -10
- package/dist/esm/components/AlphaButton/Button.mjs.map +1 -1
- package/dist/esm/components/AlphaFloatingButton/FloatingButton.mjs +18 -9
- package/dist/esm/components/AlphaFloatingButton/FloatingButton.mjs.map +1 -1
- package/dist/esm/components/AlphaFloatingIconButton/FloatingIconButton.mjs +55 -0
- package/dist/esm/components/AlphaFloatingIconButton/FloatingIconButton.mjs.map +1 -0
- package/dist/esm/components/AlphaFloatingIconButton/FloatingIconButton.module.scss.mjs +4 -0
- package/dist/esm/components/AlphaFloatingIconButton/FloatingIconButton.module.scss.mjs.map +1 -0
- package/dist/esm/components/AlphaIconButton/IconButton.mjs +5 -5
- package/dist/esm/components/AlphaIconButton/IconButton.mjs.map +1 -1
- package/dist/esm/index.mjs +1 -0
- package/dist/esm/index.mjs.map +1 -1
- package/dist/esm/styles.css +1 -1
- package/dist/types/components/AlphaButton/Button.d.ts.map +1 -1
- package/dist/types/components/AlphaButton/Button.types.d.ts +3 -2
- package/dist/types/components/AlphaButton/Button.types.d.ts.map +1 -1
- package/dist/types/components/AlphaFloatingButton/FloatingButton.d.ts.map +1 -1
- package/dist/types/components/AlphaFloatingButton/FloatingButton.types.d.ts +3 -2
- package/dist/types/components/AlphaFloatingButton/FloatingButton.types.d.ts.map +1 -1
- package/dist/types/components/AlphaFloatingIconButton/FloatingIconButton.d.ts +4 -0
- package/dist/types/components/AlphaFloatingIconButton/FloatingIconButton.d.ts.map +1 -0
- package/dist/types/components/AlphaFloatingIconButton/FloatingIconButton.types.d.ts +37 -0
- package/dist/types/components/AlphaFloatingIconButton/FloatingIconButton.types.d.ts.map +1 -0
- package/dist/types/components/AlphaFloatingIconButton/index.d.ts +3 -0
- package/dist/types/components/AlphaFloatingIconButton/index.d.ts.map +1 -0
- package/dist/types/components/AlphaIconButton/IconButton.d.ts.map +1 -1
- package/dist/types/components/AlphaIconButton/IconButton.types.d.ts +3 -2
- package/dist/types/components/AlphaIconButton/IconButton.types.d.ts.map +1 -1
- package/dist/types/components/AlphaIconButton/index.d.ts +1 -1
- package/dist/types/components/AlphaIconButton/index.d.ts.map +1 -1
- package/dist/types/index.d.ts +1 -0
- package/dist/types/index.d.ts.map +1 -1
- package/package.json +1 -1
- package/src/components/AlphaButton/AlphaButton.stories.tsx +2 -2
- package/src/components/AlphaButton/Button.tsx +34 -20
- package/src/components/AlphaButton/Button.types.ts +4 -2
- package/src/components/AlphaFloatingButton/AlphaFloatingButton.stories.tsx +2 -2
- package/src/components/AlphaFloatingButton/FloatingButton.tsx +30 -17
- package/src/components/AlphaFloatingButton/FloatingButton.types.ts +4 -2
- package/src/components/AlphaFloatingIconButton/AlphaFloatingIconButton.stories.tsx +28 -0
- package/src/components/AlphaFloatingIconButton/FloatingIconButton.module.scss +175 -0
- package/src/components/AlphaFloatingIconButton/FloatingIconButton.tsx +91 -0
- package/src/components/AlphaFloatingIconButton/FloatingIconButton.types.ts +64 -0
- package/src/components/AlphaFloatingIconButton/index.ts +2 -0
- package/src/components/AlphaIconButton/AlphaIconButton.stories.tsx +1 -1
- package/src/components/AlphaIconButton/IconButton.tsx +6 -4
- package/src/components/AlphaIconButton/IconButton.types.ts +5 -3
- package/src/components/AlphaIconButton/index.ts +1 -1
- package/src/index.ts +1 -0
|
@@ -0,0 +1,91 @@
|
|
|
1
|
+
import React, { forwardRef } from 'react'
|
|
2
|
+
|
|
3
|
+
import { isBezierIcon } from '@channel.io/bezier-icons'
|
|
4
|
+
import classNames from 'classnames'
|
|
5
|
+
|
|
6
|
+
import { type AlphaFloatingIconButtonProps } from '~/src/components/AlphaFloatingIconButton'
|
|
7
|
+
import { BaseButton } from '~/src/components/BaseButton'
|
|
8
|
+
import { type ButtonSize } from '~/src/components/Button'
|
|
9
|
+
import { Icon } from '~/src/components/Icon'
|
|
10
|
+
import { Spinner } from '~/src/components/Spinner'
|
|
11
|
+
|
|
12
|
+
import styles from './FloatingIconButton.module.scss'
|
|
13
|
+
|
|
14
|
+
function getIconSize(size: ButtonSize) {
|
|
15
|
+
return (
|
|
16
|
+
{
|
|
17
|
+
xs: 'xxs',
|
|
18
|
+
s: 'xs',
|
|
19
|
+
m: 's',
|
|
20
|
+
l: 's',
|
|
21
|
+
xl: 'm',
|
|
22
|
+
} as const
|
|
23
|
+
)[size]
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
function getSpinnerSize(size: ButtonSize) {
|
|
27
|
+
return (
|
|
28
|
+
{
|
|
29
|
+
xs: 'xs',
|
|
30
|
+
s: 'xs',
|
|
31
|
+
m: 's',
|
|
32
|
+
l: 's',
|
|
33
|
+
xl: 's',
|
|
34
|
+
} as const
|
|
35
|
+
)[size]
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
export const FloatingIconButton = forwardRef<
|
|
39
|
+
HTMLButtonElement,
|
|
40
|
+
AlphaFloatingIconButtonProps
|
|
41
|
+
>(function FloatingIconButton(
|
|
42
|
+
{
|
|
43
|
+
as = BaseButton,
|
|
44
|
+
color = 'blue',
|
|
45
|
+
variant = 'primary',
|
|
46
|
+
size = 'm',
|
|
47
|
+
active,
|
|
48
|
+
content,
|
|
49
|
+
loading,
|
|
50
|
+
className,
|
|
51
|
+
...rest
|
|
52
|
+
},
|
|
53
|
+
forwardedRef
|
|
54
|
+
) {
|
|
55
|
+
const Comp = as as typeof BaseButton
|
|
56
|
+
|
|
57
|
+
return (
|
|
58
|
+
<Comp
|
|
59
|
+
ref={forwardedRef}
|
|
60
|
+
className={classNames(
|
|
61
|
+
styles.FloatingIconButton,
|
|
62
|
+
styles[`size-${size}`],
|
|
63
|
+
styles[`variant-${variant}`],
|
|
64
|
+
styles[`color-${color}`],
|
|
65
|
+
active && styles.active,
|
|
66
|
+
className
|
|
67
|
+
)}
|
|
68
|
+
{...rest}
|
|
69
|
+
>
|
|
70
|
+
<div
|
|
71
|
+
className={classNames(styles.ButtonContent, loading && styles.loading)}
|
|
72
|
+
>
|
|
73
|
+
{isBezierIcon(content) ? (
|
|
74
|
+
<Icon
|
|
75
|
+
size={getIconSize(size)}
|
|
76
|
+
source={content}
|
|
77
|
+
/>
|
|
78
|
+
) : (
|
|
79
|
+
content
|
|
80
|
+
)}
|
|
81
|
+
</div>
|
|
82
|
+
|
|
83
|
+
{/* TODO: use AlphaSpinner */}
|
|
84
|
+
{loading && (
|
|
85
|
+
<div className={styles.ButtonLoader}>
|
|
86
|
+
<Spinner size={getSpinnerSize(size)} />
|
|
87
|
+
</div>
|
|
88
|
+
)}
|
|
89
|
+
</Comp>
|
|
90
|
+
)
|
|
91
|
+
})
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
import { type ReactNode } from 'react'
|
|
2
|
+
|
|
3
|
+
import { type BezierIcon } from '@channel.io/bezier-icons'
|
|
4
|
+
|
|
5
|
+
import {
|
|
6
|
+
type BezierComponentProps,
|
|
7
|
+
type DisableProps,
|
|
8
|
+
type PolymorphicProps,
|
|
9
|
+
type SizeProps,
|
|
10
|
+
} from '~/src/types/props'
|
|
11
|
+
|
|
12
|
+
type FloatingIconButtonVariant = 'primary' | 'secondary'
|
|
13
|
+
|
|
14
|
+
type FloatingIconButtonColor =
|
|
15
|
+
| 'blue'
|
|
16
|
+
| 'cobalt'
|
|
17
|
+
| 'red'
|
|
18
|
+
| 'orange'
|
|
19
|
+
| 'green'
|
|
20
|
+
| 'pink'
|
|
21
|
+
| 'purple'
|
|
22
|
+
| 'dark-grey'
|
|
23
|
+
| 'light-grey'
|
|
24
|
+
|
|
25
|
+
type FloatingIconButtonSize = 'xs' | 's' | 'm' | 'l' | 'xl'
|
|
26
|
+
|
|
27
|
+
interface FloatingIconButtonOwnProps {
|
|
28
|
+
/**
|
|
29
|
+
* If `loading` is true, spinner will be shown, replacing the content.
|
|
30
|
+
* @default false
|
|
31
|
+
*/
|
|
32
|
+
loading?: boolean
|
|
33
|
+
|
|
34
|
+
/**
|
|
35
|
+
* If `active` is true, the button will be styled as if it is hovered.
|
|
36
|
+
* You may want to use this prop for a button which opens dropdown, etc.
|
|
37
|
+
* @default false
|
|
38
|
+
*/
|
|
39
|
+
active?: boolean
|
|
40
|
+
|
|
41
|
+
/**
|
|
42
|
+
* Types of visual styles for button.
|
|
43
|
+
* @default 'primary'
|
|
44
|
+
*/
|
|
45
|
+
variant?: FloatingIconButtonVariant
|
|
46
|
+
|
|
47
|
+
/**
|
|
48
|
+
* Color of the button.
|
|
49
|
+
* @default 'blue'
|
|
50
|
+
*/
|
|
51
|
+
color?: FloatingIconButtonColor
|
|
52
|
+
|
|
53
|
+
/**
|
|
54
|
+
* Icon in the button.
|
|
55
|
+
*/
|
|
56
|
+
content: BezierIcon | ReactNode
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
export interface FloatingIconButtonProps
|
|
60
|
+
extends Omit<BezierComponentProps<'button'>, 'color' | 'content'>,
|
|
61
|
+
PolymorphicProps,
|
|
62
|
+
SizeProps<FloatingIconButtonSize>,
|
|
63
|
+
DisableProps,
|
|
64
|
+
FloatingIconButtonOwnProps {}
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import React, { forwardRef } from 'react'
|
|
2
2
|
|
|
3
|
+
import { isBezierIcon } from '@channel.io/bezier-icons'
|
|
3
4
|
import classNames from 'classnames'
|
|
4
5
|
|
|
5
6
|
import { type AlphaIconButtonProps } from '~/src/components/AlphaIconButton'
|
|
@@ -41,10 +42,9 @@ export const IconButton = forwardRef<HTMLButtonElement, AlphaIconButtonProps>(
|
|
|
41
42
|
color = 'blue',
|
|
42
43
|
variant = 'primary',
|
|
43
44
|
size = 'm',
|
|
44
|
-
disabled,
|
|
45
45
|
active,
|
|
46
46
|
shape = 'rectangle',
|
|
47
|
-
|
|
47
|
+
content,
|
|
48
48
|
loading,
|
|
49
49
|
className,
|
|
50
50
|
...rest
|
|
@@ -73,12 +73,14 @@ export const IconButton = forwardRef<HTMLButtonElement, AlphaIconButtonProps>(
|
|
|
73
73
|
loading && styles.loading
|
|
74
74
|
)}
|
|
75
75
|
>
|
|
76
|
-
{
|
|
76
|
+
{isBezierIcon(content) ? (
|
|
77
77
|
<Icon
|
|
78
78
|
size={getIconSize(size)}
|
|
79
|
-
source={
|
|
79
|
+
source={content}
|
|
80
80
|
className={styles.ButtonIcon}
|
|
81
81
|
/>
|
|
82
|
+
) : (
|
|
83
|
+
content
|
|
82
84
|
)}
|
|
83
85
|
</div>
|
|
84
86
|
|
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
import { type ReactNode } from 'react'
|
|
2
|
+
|
|
1
3
|
import { type BezierIcon } from '@channel.io/bezier-icons'
|
|
2
4
|
|
|
3
5
|
import {
|
|
@@ -52,7 +54,7 @@ interface IconButtonOwnProps {
|
|
|
52
54
|
/**
|
|
53
55
|
* Icon in the button.
|
|
54
56
|
*/
|
|
55
|
-
|
|
57
|
+
content: BezierIcon | ReactNode
|
|
56
58
|
|
|
57
59
|
/**
|
|
58
60
|
* Shape of the button.
|
|
@@ -61,8 +63,8 @@ interface IconButtonOwnProps {
|
|
|
61
63
|
shape?: 'rectangle' | 'circle'
|
|
62
64
|
}
|
|
63
65
|
|
|
64
|
-
export interface
|
|
65
|
-
extends Omit<BezierComponentProps<'button'>, 'color'>,
|
|
66
|
+
export interface IconButtonProps
|
|
67
|
+
extends Omit<BezierComponentProps<'button'>, 'color' | 'content'>,
|
|
66
68
|
PolymorphicProps,
|
|
67
69
|
SizeProps<IconButtonSize>,
|
|
68
70
|
DisableProps,
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
export { IconButton as AlphaIconButton } from './IconButton'
|
|
2
|
-
export type {
|
|
2
|
+
export type { IconButtonProps as AlphaIconButtonProps } from './IconButton.types'
|
package/src/index.ts
CHANGED
|
@@ -10,6 +10,7 @@ export * from '~/src/components/AlphaAvatarGroup'
|
|
|
10
10
|
export * from '~/src/components/AlphaButton'
|
|
11
11
|
export * from '~/src/components/AlphaDialogPrimitive'
|
|
12
12
|
export * from '~/src/components/AlphaFloatingButton'
|
|
13
|
+
export * from '~/src/components/AlphaFloatingIconButton'
|
|
13
14
|
export * from '~/src/components/AlphaIconButton'
|
|
14
15
|
export * from '~/src/components/AlphaTooltipPrimitive'
|
|
15
16
|
export * from '~/src/components/AppProvider'
|