forstok-ui-lib 1.0.11 → 1.0.13
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/index.d.ts +17 -2
- package/dist/index.js +56 -19
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +56 -19
- package/dist/index.mjs.map +1 -1
- package/package.json +2 -1
- package/rollup.config.js +3 -1
- package/src/assets/images/icons/arrow-left-blue.svg +10 -0
- package/src/assets/images/icons/check-white.svg +10 -0
- package/src/assets/images/icons/checkmark-tick-grey.svg +10 -0
- package/src/assets/images/icons/checkmark-tick.svg +10 -0
- package/src/assets/images/icons/close-white.svg +9 -0
- package/src/assets/images/icons/close.svg +9 -0
- package/src/assets/images/icons/dotted.svg +5 -0
- package/src/assets/images/icons/search.svg +4 -0
- package/src/assets/images/icons/warning-white.svg +4 -0
- package/src/assets/images/icons/warning.svg +9 -0
- package/src/components/button/button.styles.ts +238 -0
- package/src/components/button/button.tsx +44 -0
- package/src/components/index.ts +2 -1
- package/src/declarations.d.ts +54 -0
- package/tsconfig.json +2 -1
|
@@ -0,0 +1,238 @@
|
|
|
1
|
+
import styled, { css } from 'styled-components';
|
|
2
|
+
import IconDotted from '../../assets/images/icons/dotted.svg';
|
|
3
|
+
import IconClose from '../../assets/images/icons/close.svg';
|
|
4
|
+
import IconCloseWhite from '../../assets/images/icons/close-white.svg';
|
|
5
|
+
|
|
6
|
+
const IconStyles = css`
|
|
7
|
+
display: inline-block;
|
|
8
|
+
pointer-events: none;
|
|
9
|
+
`
|
|
10
|
+
|
|
11
|
+
const getButtonModifiedStyled = ({ $mode, $isIndicatorArrow, $isShown, $isLoading, $activated, $size, disabled, $iconLeft, $shadow }: { $mode?: string, $isIndicatorArrow: boolean, $isShown: boolean, $isLoading: boolean, $activated: boolean, $size?: string, disabled: boolean, $iconLeft?: string, $shadow: boolean }) => {
|
|
12
|
+
let style = ``;
|
|
13
|
+
if (!$isShown) {
|
|
14
|
+
return `display:none;`
|
|
15
|
+
}
|
|
16
|
+
if ($shadow) {
|
|
17
|
+
style += `
|
|
18
|
+
box-shadow: var(--act-shd-bx);
|
|
19
|
+
`
|
|
20
|
+
}
|
|
21
|
+
if ($size) {
|
|
22
|
+
if ($size === 'xsmall') {
|
|
23
|
+
style += `
|
|
24
|
+
font-size: 12px;
|
|
25
|
+
height: 20px;
|
|
26
|
+
padding: 0 8px;
|
|
27
|
+
`
|
|
28
|
+
} else if ($size === 'small') {
|
|
29
|
+
style += `
|
|
30
|
+
font-size: 13px;
|
|
31
|
+
height: 28px;
|
|
32
|
+
min-width: 75px;
|
|
33
|
+
`
|
|
34
|
+
} else if ($size === 'medium') {
|
|
35
|
+
style += `
|
|
36
|
+
height: 32px;
|
|
37
|
+
`
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
if ($mode === 'red') {
|
|
41
|
+
style += `
|
|
42
|
+
color: var(--act-clr);
|
|
43
|
+
background-color: var(--act-clr-bg);
|
|
44
|
+
&:hover {
|
|
45
|
+
background-color: var(--act-clr-bg__hvr);
|
|
46
|
+
}
|
|
47
|
+
& ${IndicatorsArrowIconSvg} {
|
|
48
|
+
fill: #ffffff;
|
|
49
|
+
stroke: #ffffff;
|
|
50
|
+
}
|
|
51
|
+
`
|
|
52
|
+
} else if ($mode === 'white') {
|
|
53
|
+
style += `
|
|
54
|
+
color: var(--mt-clr);
|
|
55
|
+
background-color: var(--cl-clr-bg);
|
|
56
|
+
border: 1px solid var(--sec-clr-ln);
|
|
57
|
+
&:hover {
|
|
58
|
+
background-color: var(--cl-clr-bg__hvr);
|
|
59
|
+
}
|
|
60
|
+
`
|
|
61
|
+
} else if ($mode === 'blue') {
|
|
62
|
+
style += `
|
|
63
|
+
&, &:hover {
|
|
64
|
+
background-color: var(--ck-clr-bg__act);
|
|
65
|
+
color: var(--act-clr);
|
|
66
|
+
}
|
|
67
|
+
& ${IndicatorsArrowIconSvg} {
|
|
68
|
+
fill: #ffffff;
|
|
69
|
+
stroke: #ffffff;
|
|
70
|
+
}
|
|
71
|
+
`
|
|
72
|
+
} else if ($mode === 'nude') {
|
|
73
|
+
style += `
|
|
74
|
+
&, &:hover {
|
|
75
|
+
background-color: var(--ter-clr-bg);
|
|
76
|
+
}
|
|
77
|
+
`
|
|
78
|
+
} else if ($mode === 'clearL') {
|
|
79
|
+
style +=`
|
|
80
|
+
width: auto;
|
|
81
|
+
height: auto;
|
|
82
|
+
color: var(--pri-clr-lnk__hvr);
|
|
83
|
+
text-decoration: none;
|
|
84
|
+
padding: 0;
|
|
85
|
+
margin: 0;
|
|
86
|
+
&, &:hover {
|
|
87
|
+
background-color: transparent;
|
|
88
|
+
}
|
|
89
|
+
&:hover {
|
|
90
|
+
opacity: .9;
|
|
91
|
+
}
|
|
92
|
+
`
|
|
93
|
+
} else if ($mode === 'clearB') {
|
|
94
|
+
style += `
|
|
95
|
+
background-color: var(--cl-clr-bg);
|
|
96
|
+
color: var(--pri-clr-lnk__hvr);
|
|
97
|
+
svg {
|
|
98
|
+
fill: var(--pri-clr-lnk__hvr);
|
|
99
|
+
stroke: var(--pri-clr-lnk__hvr);
|
|
100
|
+
}
|
|
101
|
+
& ${IndicatorsArrowIconSvg} {
|
|
102
|
+
width: 14px;
|
|
103
|
+
height: 14px;
|
|
104
|
+
margin-top: -7px;
|
|
105
|
+
}
|
|
106
|
+
&:disabled {
|
|
107
|
+
span {color: var(--mt-clr);}
|
|
108
|
+
}
|
|
109
|
+
`
|
|
110
|
+
} else if ($mode === 'clear') {
|
|
111
|
+
style +=`
|
|
112
|
+
box-shadow: none !important;
|
|
113
|
+
&, &:hover {
|
|
114
|
+
background-color: transparent;
|
|
115
|
+
}
|
|
116
|
+
`
|
|
117
|
+
if ($activated) {
|
|
118
|
+
style += `
|
|
119
|
+
color: var(--pri-clr) !important;
|
|
120
|
+
font-weight: 600;
|
|
121
|
+
`
|
|
122
|
+
}
|
|
123
|
+
} else if ($mode === 'more') {
|
|
124
|
+
style += `
|
|
125
|
+
padding: 8px;
|
|
126
|
+
background-color: var(--mt-clr-bg__fc);
|
|
127
|
+
&:before {
|
|
128
|
+
content: url(${IconDotted});
|
|
129
|
+
height: 14px;
|
|
130
|
+
width: 14px;
|
|
131
|
+
${IconStyles}
|
|
132
|
+
}
|
|
133
|
+
`
|
|
134
|
+
} else if ($mode === 'round-close') {
|
|
135
|
+
style += `
|
|
136
|
+
background-color: transparent;
|
|
137
|
+
&:before {
|
|
138
|
+
content: url(${IconClose});
|
|
139
|
+
width: 12px;
|
|
140
|
+
${IconStyles}
|
|
141
|
+
}
|
|
142
|
+
`
|
|
143
|
+
} else if ($mode === 'small-white-round-close') {
|
|
144
|
+
style += `
|
|
145
|
+
background-color: transparent;
|
|
146
|
+
&:before {
|
|
147
|
+
content: url(${IconCloseWhite});
|
|
148
|
+
width: 8px;
|
|
149
|
+
${IconStyles}
|
|
150
|
+
}
|
|
151
|
+
`
|
|
152
|
+
} else if ($mode === 'page-option') {
|
|
153
|
+
style += `
|
|
154
|
+
border: 1px solid var(--ck-clr-ln);
|
|
155
|
+
background-color: transparent;
|
|
156
|
+
font-weight: 600;
|
|
157
|
+
cursor: pointer;
|
|
158
|
+
border-radius: var(--ter-rd);
|
|
159
|
+
padding: 6px 12px;
|
|
160
|
+
height: 28px;
|
|
161
|
+
& ${IndicatorsArrowIconSvg} {
|
|
162
|
+
width: 14px;
|
|
163
|
+
height: 14px;
|
|
164
|
+
margin-top: -7px;
|
|
165
|
+
}
|
|
166
|
+
`
|
|
167
|
+
}
|
|
168
|
+
if (disabled) {
|
|
169
|
+
style += `
|
|
170
|
+
&, &:hover {
|
|
171
|
+
background-color: var(--mt-clr-bg__fc) !important;
|
|
172
|
+
cursor: default;
|
|
173
|
+
color: var(--mt-clr);
|
|
174
|
+
}
|
|
175
|
+
`
|
|
176
|
+
}
|
|
177
|
+
if ($iconLeft) {
|
|
178
|
+
style += ` padding-left: 35px; `
|
|
179
|
+
}
|
|
180
|
+
if ($isIndicatorArrow) {
|
|
181
|
+
style += `
|
|
182
|
+
padding-right: 25px;
|
|
183
|
+
`
|
|
184
|
+
}
|
|
185
|
+
if ($isLoading) {
|
|
186
|
+
style += `
|
|
187
|
+
padding-right: 30px !important;
|
|
188
|
+
`
|
|
189
|
+
}
|
|
190
|
+
return style;
|
|
191
|
+
}
|
|
192
|
+
const getIndicatorsArrowIconSvgModifiedStyled = ({ color }:{ color?: string }) => {
|
|
193
|
+
let style = ``;
|
|
194
|
+
if (color && color !== 'initial') {
|
|
195
|
+
style += `
|
|
196
|
+
fill: ${color};
|
|
197
|
+
stroke: ${color};
|
|
198
|
+
`
|
|
199
|
+
}
|
|
200
|
+
return style;
|
|
201
|
+
}
|
|
202
|
+
|
|
203
|
+
export const ButtonContainer = styled.button<{ $mode?: string, $isIndicatorArrow: boolean, $isShown: boolean, $isLoading: boolean, $activated: boolean, $size?: string, disabled: boolean, $iconLeft?: string, $shadow: boolean }>`
|
|
204
|
+
> span {
|
|
205
|
+
white-space: nowrap;
|
|
206
|
+
overflow: hidden;
|
|
207
|
+
text-overflow: ellipsis;
|
|
208
|
+
}
|
|
209
|
+
._refLoading {
|
|
210
|
+
position: absolute;
|
|
211
|
+
right: 10px;
|
|
212
|
+
top: 50%;
|
|
213
|
+
margin-top: -8px;
|
|
214
|
+
}
|
|
215
|
+
&._refButtonLoading._refHidden {
|
|
216
|
+
padding-right: 16px !important;
|
|
217
|
+
}
|
|
218
|
+
&._refButtonLoading {
|
|
219
|
+
padding-right: 30px !important;
|
|
220
|
+
|
|
221
|
+
}
|
|
222
|
+
${getButtonModifiedStyled}
|
|
223
|
+
|
|
224
|
+
`
|
|
225
|
+
export const IndicatorsArrowIconSvg = styled.svg`
|
|
226
|
+
display: inline-block;
|
|
227
|
+
fill: currentColor;
|
|
228
|
+
stroke: currentColor;
|
|
229
|
+
stroke-width: 0;
|
|
230
|
+
position: absolute;
|
|
231
|
+
right: 8px;
|
|
232
|
+
top: 50%;
|
|
233
|
+
margin-top: -10px;
|
|
234
|
+
width: 14px;
|
|
235
|
+
height: 14px;
|
|
236
|
+
margin-top: -7px;
|
|
237
|
+
${getIndicatorsArrowIconSvgModifiedStyled}
|
|
238
|
+
`
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
import type { ButtonHTMLAttributes, ReactNode, RefObject } from 'react' ;
|
|
2
|
+
import { ButtonContainer, IndicatorsArrowIconSvg } from './button.styles';
|
|
3
|
+
|
|
4
|
+
type TButton = ButtonHTMLAttributes<HTMLButtonElement> & {
|
|
5
|
+
children?: ReactNode
|
|
6
|
+
$mode?: string
|
|
7
|
+
$isIndicatorArrow?: boolean
|
|
8
|
+
isIndicatorArrowColor?: string
|
|
9
|
+
$isShown?: boolean
|
|
10
|
+
$isLoading?: boolean
|
|
11
|
+
refContainer?: RefObject<HTMLButtonElement>
|
|
12
|
+
$activated?: boolean
|
|
13
|
+
$size?: string
|
|
14
|
+
$iconLeft?: string
|
|
15
|
+
$shadow?: boolean
|
|
16
|
+
};
|
|
17
|
+
|
|
18
|
+
const ButtonComponent = ({ children, $mode, $isIndicatorArrow=false, isIndicatorArrowColor='initial', $isShown=true, $shadow=false, $isLoading=false, refContainer, $activated=false, $size, $iconLeft, ...props }: TButton) => {
|
|
19
|
+
const { disabled } = props;
|
|
20
|
+
const IndicatorArrowIconEl = $isIndicatorArrow ? (
|
|
21
|
+
<IndicatorsArrowIconSvg color={isIndicatorArrowColor} height='20' width='20' viewBox='0 0 20 20' aria-hidden='true' focusable='false'>
|
|
22
|
+
<path d='M4.516 7.548c0.436-0.446 1.043-0.481 1.576 0l3.908 3.747 3.908-3.747c0.533-0.481 1.141-0.446 1.574 0 0.436 0.445 0.408 1.197 0 1.615-0.406 0.418-4.695 4.502-4.695 4.502-0.217 0.223-0.502 0.335-0.787 0.335s-0.57-0.112-0.789-0.335c0 0-4.287-4.084-4.695-4.502s-0.436-1.17 0-1.615z'></path>
|
|
23
|
+
</IndicatorsArrowIconSvg>
|
|
24
|
+
) : null;
|
|
25
|
+
return (
|
|
26
|
+
<ButtonContainer
|
|
27
|
+
$mode={$mode}
|
|
28
|
+
$isIndicatorArrow={$isIndicatorArrow ? true : false}
|
|
29
|
+
$isShown={$isShown ? true : false}
|
|
30
|
+
$shadow={$shadow ? true : false}
|
|
31
|
+
disabled={disabled || $isLoading || false}
|
|
32
|
+
$isLoading={ $isLoading ? true : false}
|
|
33
|
+
ref={refContainer}
|
|
34
|
+
$activated={$activated ? true : false}
|
|
35
|
+
$size={$size}
|
|
36
|
+
$iconLeft={$iconLeft}
|
|
37
|
+
{...props}>
|
|
38
|
+
{children}
|
|
39
|
+
{IndicatorArrowIconEl}
|
|
40
|
+
</ButtonContainer>
|
|
41
|
+
);
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
export default ButtonComponent;
|
package/src/components/index.ts
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
export { default as TextComponent } from './text/text';
|
|
2
2
|
export { default as LinkComponent } from './link/link';
|
|
3
3
|
export { default as InputComponent } from './input/input';
|
|
4
|
-
export { default as CheckboxComponent } from './checkbox/checkbox';
|
|
4
|
+
export { default as CheckboxComponent } from './checkbox/checkbox';
|
|
5
|
+
export { default as ButtonComponent } from './button/button';
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
declare module '*.avif' {
|
|
2
|
+
const src: string;
|
|
3
|
+
export default src;
|
|
4
|
+
}
|
|
5
|
+
declare module '*.bmp' {
|
|
6
|
+
const src: string;
|
|
7
|
+
export default src;
|
|
8
|
+
}
|
|
9
|
+
declare module '*.gif' {
|
|
10
|
+
const src: string;
|
|
11
|
+
export default src;
|
|
12
|
+
}
|
|
13
|
+
declare module '*.jpg' {
|
|
14
|
+
const src: string;
|
|
15
|
+
export default src;
|
|
16
|
+
}
|
|
17
|
+
declare module '*.jpeg' {
|
|
18
|
+
const src: string;
|
|
19
|
+
export default src;
|
|
20
|
+
}
|
|
21
|
+
declare module '*.png' {
|
|
22
|
+
const src: string;
|
|
23
|
+
export default src;
|
|
24
|
+
}
|
|
25
|
+
declare module '*.webp' {
|
|
26
|
+
const src: string;
|
|
27
|
+
export default src;
|
|
28
|
+
}
|
|
29
|
+
declare module '*.svg' {
|
|
30
|
+
import type { FunctionComponent, SVGProps } from 'react'
|
|
31
|
+
export const ReactComponent: FunctionComponent & SVGProps<{ title?: string }>;
|
|
32
|
+
const src: string;
|
|
33
|
+
export default src;
|
|
34
|
+
}
|
|
35
|
+
declare module '*.mp3' {
|
|
36
|
+
const src: string;
|
|
37
|
+
export default src;
|
|
38
|
+
}
|
|
39
|
+
declare module '*.wav' {
|
|
40
|
+
const src: string;
|
|
41
|
+
export default src;
|
|
42
|
+
}
|
|
43
|
+
declare module '*.module.css' {
|
|
44
|
+
const classes: { readonly [key: string]: string };
|
|
45
|
+
export default classes;
|
|
46
|
+
}
|
|
47
|
+
declare module '*.module.scss' {
|
|
48
|
+
const classes: { readonly [key: string]: string };
|
|
49
|
+
export default classes;
|
|
50
|
+
}
|
|
51
|
+
declare module '*.module.sass' {
|
|
52
|
+
const classes: { readonly [key: string]: string };
|
|
53
|
+
export default classes;
|
|
54
|
+
}
|