@dktunited-techoff/techoff-suite-ui 1.4.4 → 1.5.0
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/esm/components/TsCheckbox/TsCheckbox.css +73 -0
- package/esm/components/TsCheckbox/TsCheckbox.d.ts +4 -0
- package/esm/components/TsCheckbox/TsCheckbox.js +17 -0
- package/esm/components/TsCheckbox/TsCheckbox.js.map +1 -0
- package/esm/components/TsCheckbox/TsCheckbox.types.d.ts +7 -0
- package/esm/components/TsCheckbox/TsCheckbox.types.js +2 -0
- package/esm/components/TsCheckbox/TsCheckbox.types.js.map +1 -0
- package/esm/components/TsCheckbox/__stories__/TsCheckbox.stories.mdx +56 -0
- package/esm/index.d.ts +1 -0
- package/esm/index.js +1 -0
- package/esm/index.js.map +1 -1
- package/lib/components/TsCheckbox/TsCheckbox.css +73 -0
- package/lib/components/TsCheckbox/TsCheckbox.d.ts +4 -0
- package/lib/components/TsCheckbox/TsCheckbox.js +21 -0
- package/lib/components/TsCheckbox/TsCheckbox.js.map +1 -0
- package/lib/components/TsCheckbox/TsCheckbox.types.d.ts +7 -0
- package/lib/components/TsCheckbox/TsCheckbox.types.js +3 -0
- package/lib/components/TsCheckbox/TsCheckbox.types.js.map +1 -0
- package/lib/components/TsCheckbox/__stories__/TsCheckbox.stories.mdx +56 -0
- package/lib/index.d.ts +1 -0
- package/lib/index.js +1 -0
- package/lib/index.js.map +1 -1
- package/package.json +1 -1
- package/src/components/TsCheckbox/TsCheckbox.css +73 -0
- package/src/components/TsCheckbox/TsCheckbox.tsx +25 -0
- package/src/components/TsCheckbox/TsCheckbox.types.ts +7 -0
- package/src/components/TsCheckbox/__stories__/TsCheckbox.stories.mdx +56 -0
- package/src/index.ts +1 -0
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
.ts-checkbox {
|
|
2
|
+
display: flex;
|
|
3
|
+
align-items: center;
|
|
4
|
+
cursor: pointer;
|
|
5
|
+
}
|
|
6
|
+
/* ########## */
|
|
7
|
+
/* DISABLED */
|
|
8
|
+
.ts-checkbox--disabled {
|
|
9
|
+
cursor: not-allowed;
|
|
10
|
+
}
|
|
11
|
+
.ts-checkbox--disabled .ts-checkbox-box {
|
|
12
|
+
color: #d7daf1;
|
|
13
|
+
}
|
|
14
|
+
.ts-checkbox--disabled:hover .ts-checkbox-box {
|
|
15
|
+
background: transparent;
|
|
16
|
+
}
|
|
17
|
+
/* ##### */
|
|
18
|
+
/* BOX */
|
|
19
|
+
.ts-checkbox:not(.ts-checkbox--disabled):hover .ts-checkbox-box {
|
|
20
|
+
background: #e1e3f5;
|
|
21
|
+
}
|
|
22
|
+
.ts-checkbox-box {
|
|
23
|
+
position: relative;
|
|
24
|
+
display: flex;
|
|
25
|
+
align-items: center;
|
|
26
|
+
justify-content: center;
|
|
27
|
+
width: 24px;
|
|
28
|
+
min-width: 24px;
|
|
29
|
+
height: 24px;
|
|
30
|
+
min-height: 24px;
|
|
31
|
+
border-radius: 6px;
|
|
32
|
+
color: #3643ba;
|
|
33
|
+
transition: all ease 0.3s;
|
|
34
|
+
}
|
|
35
|
+
.ts-checkbox-box::before {
|
|
36
|
+
content: '';
|
|
37
|
+
position: absolute;
|
|
38
|
+
width: 12px;
|
|
39
|
+
height: 12px;
|
|
40
|
+
border-radius: 6px;
|
|
41
|
+
background: #ffffff;
|
|
42
|
+
z-index: 10;
|
|
43
|
+
}
|
|
44
|
+
.ts-checkbox-box .ts-icon {
|
|
45
|
+
z-index: 20;
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
/* ################# */
|
|
49
|
+
/* LABEL / CAPTION */
|
|
50
|
+
.ts-checkbox-container {
|
|
51
|
+
width: 100%;
|
|
52
|
+
padding: 4px 8px;
|
|
53
|
+
border-radius: 6px;
|
|
54
|
+
}
|
|
55
|
+
.ts-checkbox-container--with-caption .ts-checkbox-label {
|
|
56
|
+
color: #3643ba;
|
|
57
|
+
font-weight: 700;
|
|
58
|
+
}
|
|
59
|
+
.ts-checkbox-caption {
|
|
60
|
+
color: #404040;
|
|
61
|
+
font-size: 12px;
|
|
62
|
+
font-style: italic;
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
/* ######### */
|
|
66
|
+
/* GLOBALS */
|
|
67
|
+
* {
|
|
68
|
+
font-size: 14px;
|
|
69
|
+
outline: none;
|
|
70
|
+
box-sizing: border-box;
|
|
71
|
+
font-family: system-ui, -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, 'Open Sans',
|
|
72
|
+
'Helvetica Neue', sans-serif;
|
|
73
|
+
}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import * as React from 'react';
|
|
2
|
+
import { TsIcon } from '../TsIcon/TsIcon';
|
|
3
|
+
import './TsCheckbox.css';
|
|
4
|
+
export const TsCheckbox = ({ caption, label, checked, disabled, onChange }) => {
|
|
5
|
+
// ########
|
|
6
|
+
// Handlers
|
|
7
|
+
const handleChange = () => !disabled && onChange(!checked);
|
|
8
|
+
// #########
|
|
9
|
+
// Rendering
|
|
10
|
+
return (React.createElement("div", { className: `ts-checkbox ${disabled ? 'ts-checkbox--disabled' : ''}`, onClick: handleChange },
|
|
11
|
+
React.createElement("div", { className: "ts-checkbox-box" },
|
|
12
|
+
React.createElement(TsIcon, { name: checked ? 'check-square-filled' : 'square' })),
|
|
13
|
+
React.createElement("div", { className: `ts-checkbox-container ${caption ? 'ts-checkbox-container--with-caption' : ''}` },
|
|
14
|
+
React.createElement("div", { className: "ts-checkbox-label" }, label),
|
|
15
|
+
caption && React.createElement("div", { className: "ts-checkbox-caption" }, caption))));
|
|
16
|
+
};
|
|
17
|
+
//# sourceMappingURL=TsCheckbox.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"TsCheckbox.js","sourceRoot":"","sources":["../../../src/components/TsCheckbox/TsCheckbox.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAC/B,OAAO,EAAE,MAAM,EAAE,MAAM,kBAAkB,CAAC;AAE1C,OAAO,kBAAkB,CAAC;AAE1B,MAAM,CAAC,MAAM,UAAU,GAAG,CAAC,EAAE,OAAO,EAAE,KAAK,EAAE,OAAO,EAAE,QAAQ,EAAE,QAAQ,EAAmB,EAAE,EAAE;IAC7F,WAAW;IACX,WAAW;IACX,MAAM,YAAY,GAAG,GAAG,EAAE,CAAC,CAAC,QAAQ,IAAI,QAAQ,CAAC,CAAC,OAAO,CAAC,CAAC;IAE3D,YAAY;IACZ,YAAY;IACZ,OAAO,CACL,6BAAK,SAAS,EAAE,eAAe,QAAQ,CAAC,CAAC,CAAC,uBAAuB,CAAC,CAAC,CAAC,EAAE,EAAE,EAAE,OAAO,EAAE,YAAY;QAC7F,6BAAK,SAAS,EAAC,iBAAiB;YAC9B,oBAAC,MAAM,IAAC,IAAI,EAAE,OAAO,CAAC,CAAC,CAAC,qBAAqB,CAAC,CAAC,CAAC,QAAQ,GAAI,CACxD;QAEN,6BAAK,SAAS,EAAE,yBAAyB,OAAO,CAAC,CAAC,CAAC,qCAAqC,CAAC,CAAC,CAAC,EAAE,EAAE;YAC7F,6BAAK,SAAS,EAAC,mBAAmB,IAAE,KAAK,CAAO;YAC/C,OAAO,IAAI,6BAAK,SAAS,EAAC,qBAAqB,IAAE,OAAO,CAAO,CAC5D,CACF,CACP,CAAC;AACJ,CAAC,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"TsCheckbox.types.js","sourceRoot":"","sources":["../../../src/components/TsCheckbox/TsCheckbox.types.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { ArgsTable, Canvas, Meta, Story } from '@storybook/blocks';
|
|
3
|
+
import { TsCheckbox } from '../TsCheckbox';
|
|
4
|
+
|
|
5
|
+
<Meta title="Components/Checkbox" />
|
|
6
|
+
|
|
7
|
+
export const checkboxArgTypes = {
|
|
8
|
+
caption: {
|
|
9
|
+
control: 'text',
|
|
10
|
+
description: 'Caption of the checkbox.',
|
|
11
|
+
},
|
|
12
|
+
label: {
|
|
13
|
+
control: 'text',
|
|
14
|
+
description: 'Label of the checkbox.',
|
|
15
|
+
},
|
|
16
|
+
checked: {
|
|
17
|
+
control: 'boolean',
|
|
18
|
+
description: 'State of the checkbox.',
|
|
19
|
+
table: { defaultValue: { summary: 'false' } },
|
|
20
|
+
},
|
|
21
|
+
disabled: {
|
|
22
|
+
control: 'boolean',
|
|
23
|
+
description: 'Enable state of the checkbox.',
|
|
24
|
+
table: { defaultValue: { summary: 'false' } },
|
|
25
|
+
},
|
|
26
|
+
onChange: {
|
|
27
|
+
control: 'function',
|
|
28
|
+
description: 'The handler called when clicking on the checkbox.',
|
|
29
|
+
},
|
|
30
|
+
};
|
|
31
|
+
|
|
32
|
+
# Checkbox
|
|
33
|
+
|
|
34
|
+
Checkboxes are applied when users can select all, several, or none of the options from a given list.
|
|
35
|
+
|
|
36
|
+
## Overview
|
|
37
|
+
|
|
38
|
+
<Canvas>
|
|
39
|
+
<Story
|
|
40
|
+
name="Overview"
|
|
41
|
+
args={{
|
|
42
|
+
label: 'Lorem ipsum dolor sit amet, consectetur adipiscing elit',
|
|
43
|
+
caption:
|
|
44
|
+
'Auctor nisl justo, sed posuere est dignissim nec. Integer ultricies, metus ac imperdiet ullamcorper, est justo viverra nisl, in posuere dui urna eget quam.',
|
|
45
|
+
checked: false,
|
|
46
|
+
disabled: false,
|
|
47
|
+
}}
|
|
48
|
+
argTypes={checkboxArgTypes}
|
|
49
|
+
>
|
|
50
|
+
{args => <TsCheckbox {...args}>{args.children}</TsCheckbox>}
|
|
51
|
+
</Story>
|
|
52
|
+
</Canvas>
|
|
53
|
+
|
|
54
|
+
## Props
|
|
55
|
+
|
|
56
|
+
<ArgsTable story="Overview" of={TsCheckbox} />
|
package/esm/index.d.ts
CHANGED
package/esm/index.js
CHANGED
package/esm/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,gCAAgC,CAAC;AAC/C,cAAc,4BAA4B,CAAC;AAC3C,cAAc,sCAAsC,CAAC;AACrD,cAAc,gCAAgC,CAAC;AAC/C,cAAc,6BAA6B,CAAC;AAC5C,cAAc,oCAAoC,CAAC;AACnD,cAAc,qCAAqC,CAAC"}
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,gCAAgC,CAAC;AAC/C,cAAc,oCAAoC,CAAC;AACnD,cAAc,4BAA4B,CAAC;AAC3C,cAAc,sCAAsC,CAAC;AACrD,cAAc,gCAAgC,CAAC;AAC/C,cAAc,6BAA6B,CAAC;AAC5C,cAAc,oCAAoC,CAAC;AACnD,cAAc,qCAAqC,CAAC"}
|
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
.ts-checkbox {
|
|
2
|
+
display: flex;
|
|
3
|
+
align-items: center;
|
|
4
|
+
cursor: pointer;
|
|
5
|
+
}
|
|
6
|
+
/* ########## */
|
|
7
|
+
/* DISABLED */
|
|
8
|
+
.ts-checkbox--disabled {
|
|
9
|
+
cursor: not-allowed;
|
|
10
|
+
}
|
|
11
|
+
.ts-checkbox--disabled .ts-checkbox-box {
|
|
12
|
+
color: #d7daf1;
|
|
13
|
+
}
|
|
14
|
+
.ts-checkbox--disabled:hover .ts-checkbox-box {
|
|
15
|
+
background: transparent;
|
|
16
|
+
}
|
|
17
|
+
/* ##### */
|
|
18
|
+
/* BOX */
|
|
19
|
+
.ts-checkbox:not(.ts-checkbox--disabled):hover .ts-checkbox-box {
|
|
20
|
+
background: #e1e3f5;
|
|
21
|
+
}
|
|
22
|
+
.ts-checkbox-box {
|
|
23
|
+
position: relative;
|
|
24
|
+
display: flex;
|
|
25
|
+
align-items: center;
|
|
26
|
+
justify-content: center;
|
|
27
|
+
width: 24px;
|
|
28
|
+
min-width: 24px;
|
|
29
|
+
height: 24px;
|
|
30
|
+
min-height: 24px;
|
|
31
|
+
border-radius: 6px;
|
|
32
|
+
color: #3643ba;
|
|
33
|
+
transition: all ease 0.3s;
|
|
34
|
+
}
|
|
35
|
+
.ts-checkbox-box::before {
|
|
36
|
+
content: '';
|
|
37
|
+
position: absolute;
|
|
38
|
+
width: 12px;
|
|
39
|
+
height: 12px;
|
|
40
|
+
border-radius: 6px;
|
|
41
|
+
background: #ffffff;
|
|
42
|
+
z-index: 10;
|
|
43
|
+
}
|
|
44
|
+
.ts-checkbox-box .ts-icon {
|
|
45
|
+
z-index: 20;
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
/* ################# */
|
|
49
|
+
/* LABEL / CAPTION */
|
|
50
|
+
.ts-checkbox-container {
|
|
51
|
+
width: 100%;
|
|
52
|
+
padding: 4px 8px;
|
|
53
|
+
border-radius: 6px;
|
|
54
|
+
}
|
|
55
|
+
.ts-checkbox-container--with-caption .ts-checkbox-label {
|
|
56
|
+
color: #3643ba;
|
|
57
|
+
font-weight: 700;
|
|
58
|
+
}
|
|
59
|
+
.ts-checkbox-caption {
|
|
60
|
+
color: #404040;
|
|
61
|
+
font-size: 12px;
|
|
62
|
+
font-style: italic;
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
/* ######### */
|
|
66
|
+
/* GLOBALS */
|
|
67
|
+
* {
|
|
68
|
+
font-size: 14px;
|
|
69
|
+
outline: none;
|
|
70
|
+
box-sizing: border-box;
|
|
71
|
+
font-family: system-ui, -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, 'Open Sans',
|
|
72
|
+
'Helvetica Neue', sans-serif;
|
|
73
|
+
}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.TsCheckbox = void 0;
|
|
4
|
+
const React = require("react");
|
|
5
|
+
const TsIcon_1 = require("../TsIcon/TsIcon");
|
|
6
|
+
require("./TsCheckbox.css");
|
|
7
|
+
const TsCheckbox = ({ caption, label, checked, disabled, onChange }) => {
|
|
8
|
+
// ########
|
|
9
|
+
// Handlers
|
|
10
|
+
const handleChange = () => !disabled && onChange(!checked);
|
|
11
|
+
// #########
|
|
12
|
+
// Rendering
|
|
13
|
+
return (React.createElement("div", { className: `ts-checkbox ${disabled ? 'ts-checkbox--disabled' : ''}`, onClick: handleChange },
|
|
14
|
+
React.createElement("div", { className: "ts-checkbox-box" },
|
|
15
|
+
React.createElement(TsIcon_1.TsIcon, { name: checked ? 'check-square-filled' : 'square' })),
|
|
16
|
+
React.createElement("div", { className: `ts-checkbox-container ${caption ? 'ts-checkbox-container--with-caption' : ''}` },
|
|
17
|
+
React.createElement("div", { className: "ts-checkbox-label" }, label),
|
|
18
|
+
caption && React.createElement("div", { className: "ts-checkbox-caption" }, caption))));
|
|
19
|
+
};
|
|
20
|
+
exports.TsCheckbox = TsCheckbox;
|
|
21
|
+
//# sourceMappingURL=TsCheckbox.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"TsCheckbox.js","sourceRoot":"","sources":["../../../src/components/TsCheckbox/TsCheckbox.tsx"],"names":[],"mappings":";;;AAAA,+BAA+B;AAC/B,6CAA0C;AAE1C,4BAA0B;AAEnB,MAAM,UAAU,GAAG,CAAC,EAAE,OAAO,EAAE,KAAK,EAAE,OAAO,EAAE,QAAQ,EAAE,QAAQ,EAAmB,EAAE,EAAE;IAC7F,WAAW;IACX,WAAW;IACX,MAAM,YAAY,GAAG,GAAG,EAAE,CAAC,CAAC,QAAQ,IAAI,QAAQ,CAAC,CAAC,OAAO,CAAC,CAAC;IAE3D,YAAY;IACZ,YAAY;IACZ,OAAO,CACL,6BAAK,SAAS,EAAE,eAAe,QAAQ,CAAC,CAAC,CAAC,uBAAuB,CAAC,CAAC,CAAC,EAAE,EAAE,EAAE,OAAO,EAAE,YAAY;QAC7F,6BAAK,SAAS,EAAC,iBAAiB;YAC9B,oBAAC,eAAM,IAAC,IAAI,EAAE,OAAO,CAAC,CAAC,CAAC,qBAAqB,CAAC,CAAC,CAAC,QAAQ,GAAI,CACxD;QAEN,6BAAK,SAAS,EAAE,yBAAyB,OAAO,CAAC,CAAC,CAAC,qCAAqC,CAAC,CAAC,CAAC,EAAE,EAAE;YAC7F,6BAAK,SAAS,EAAC,mBAAmB,IAAE,KAAK,CAAO;YAC/C,OAAO,IAAI,6BAAK,SAAS,EAAC,qBAAqB,IAAE,OAAO,CAAO,CAC5D,CACF,CACP,CAAC;AACJ,CAAC,CAAC;AAnBW,QAAA,UAAU,cAmBrB"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"TsCheckbox.types.js","sourceRoot":"","sources":["../../../src/components/TsCheckbox/TsCheckbox.types.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { ArgsTable, Canvas, Meta, Story } from '@storybook/blocks';
|
|
3
|
+
import { TsCheckbox } from '../TsCheckbox';
|
|
4
|
+
|
|
5
|
+
<Meta title="Components/Checkbox" />
|
|
6
|
+
|
|
7
|
+
export const checkboxArgTypes = {
|
|
8
|
+
caption: {
|
|
9
|
+
control: 'text',
|
|
10
|
+
description: 'Caption of the checkbox.',
|
|
11
|
+
},
|
|
12
|
+
label: {
|
|
13
|
+
control: 'text',
|
|
14
|
+
description: 'Label of the checkbox.',
|
|
15
|
+
},
|
|
16
|
+
checked: {
|
|
17
|
+
control: 'boolean',
|
|
18
|
+
description: 'State of the checkbox.',
|
|
19
|
+
table: { defaultValue: { summary: 'false' } },
|
|
20
|
+
},
|
|
21
|
+
disabled: {
|
|
22
|
+
control: 'boolean',
|
|
23
|
+
description: 'Enable state of the checkbox.',
|
|
24
|
+
table: { defaultValue: { summary: 'false' } },
|
|
25
|
+
},
|
|
26
|
+
onChange: {
|
|
27
|
+
control: 'function',
|
|
28
|
+
description: 'The handler called when clicking on the checkbox.',
|
|
29
|
+
},
|
|
30
|
+
};
|
|
31
|
+
|
|
32
|
+
# Checkbox
|
|
33
|
+
|
|
34
|
+
Checkboxes are applied when users can select all, several, or none of the options from a given list.
|
|
35
|
+
|
|
36
|
+
## Overview
|
|
37
|
+
|
|
38
|
+
<Canvas>
|
|
39
|
+
<Story
|
|
40
|
+
name="Overview"
|
|
41
|
+
args={{
|
|
42
|
+
label: 'Lorem ipsum dolor sit amet, consectetur adipiscing elit',
|
|
43
|
+
caption:
|
|
44
|
+
'Auctor nisl justo, sed posuere est dignissim nec. Integer ultricies, metus ac imperdiet ullamcorper, est justo viverra nisl, in posuere dui urna eget quam.',
|
|
45
|
+
checked: false,
|
|
46
|
+
disabled: false,
|
|
47
|
+
}}
|
|
48
|
+
argTypes={checkboxArgTypes}
|
|
49
|
+
>
|
|
50
|
+
{args => <TsCheckbox {...args}>{args.children}</TsCheckbox>}
|
|
51
|
+
</Story>
|
|
52
|
+
</Canvas>
|
|
53
|
+
|
|
54
|
+
## Props
|
|
55
|
+
|
|
56
|
+
<ArgsTable story="Overview" of={TsCheckbox} />
|
package/lib/index.d.ts
CHANGED
package/lib/index.js
CHANGED
|
@@ -15,6 +15,7 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
|
15
15
|
};
|
|
16
16
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
17
|
__exportStar(require("./components/TsButton/TsButton"), exports);
|
|
18
|
+
__exportStar(require("./components/TsCheckbox/TsCheckbox"), exports);
|
|
18
19
|
__exportStar(require("./components/TsIcon/TsIcon"), exports);
|
|
19
20
|
__exportStar(require("./components/TsInput/TsInput/TsInput"), exports);
|
|
20
21
|
__exportStar(require("./components/TsLoader/TsLoader"), exports);
|
package/lib/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,iEAA+C;AAC/C,6DAA2C;AAC3C,uEAAqD;AACrD,iEAA+C;AAC/C,8DAA4C;AAC5C,qEAAmD;AACnD,sEAAoD"}
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,iEAA+C;AAC/C,qEAAmD;AACnD,6DAA2C;AAC3C,uEAAqD;AACrD,iEAA+C;AAC/C,8DAA4C;AAC5C,qEAAmD;AACnD,sEAAoD"}
|
package/package.json
CHANGED
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
.ts-checkbox {
|
|
2
|
+
display: flex;
|
|
3
|
+
align-items: center;
|
|
4
|
+
cursor: pointer;
|
|
5
|
+
}
|
|
6
|
+
/* ########## */
|
|
7
|
+
/* DISABLED */
|
|
8
|
+
.ts-checkbox--disabled {
|
|
9
|
+
cursor: not-allowed;
|
|
10
|
+
}
|
|
11
|
+
.ts-checkbox--disabled .ts-checkbox-box {
|
|
12
|
+
color: #d7daf1;
|
|
13
|
+
}
|
|
14
|
+
.ts-checkbox--disabled:hover .ts-checkbox-box {
|
|
15
|
+
background: transparent;
|
|
16
|
+
}
|
|
17
|
+
/* ##### */
|
|
18
|
+
/* BOX */
|
|
19
|
+
.ts-checkbox:not(.ts-checkbox--disabled):hover .ts-checkbox-box {
|
|
20
|
+
background: #e1e3f5;
|
|
21
|
+
}
|
|
22
|
+
.ts-checkbox-box {
|
|
23
|
+
position: relative;
|
|
24
|
+
display: flex;
|
|
25
|
+
align-items: center;
|
|
26
|
+
justify-content: center;
|
|
27
|
+
width: 24px;
|
|
28
|
+
min-width: 24px;
|
|
29
|
+
height: 24px;
|
|
30
|
+
min-height: 24px;
|
|
31
|
+
border-radius: 6px;
|
|
32
|
+
color: #3643ba;
|
|
33
|
+
transition: all ease 0.3s;
|
|
34
|
+
}
|
|
35
|
+
.ts-checkbox-box::before {
|
|
36
|
+
content: '';
|
|
37
|
+
position: absolute;
|
|
38
|
+
width: 12px;
|
|
39
|
+
height: 12px;
|
|
40
|
+
border-radius: 6px;
|
|
41
|
+
background: #ffffff;
|
|
42
|
+
z-index: 10;
|
|
43
|
+
}
|
|
44
|
+
.ts-checkbox-box .ts-icon {
|
|
45
|
+
z-index: 20;
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
/* ################# */
|
|
49
|
+
/* LABEL / CAPTION */
|
|
50
|
+
.ts-checkbox-container {
|
|
51
|
+
width: 100%;
|
|
52
|
+
padding: 4px 8px;
|
|
53
|
+
border-radius: 6px;
|
|
54
|
+
}
|
|
55
|
+
.ts-checkbox-container--with-caption .ts-checkbox-label {
|
|
56
|
+
color: #3643ba;
|
|
57
|
+
font-weight: 700;
|
|
58
|
+
}
|
|
59
|
+
.ts-checkbox-caption {
|
|
60
|
+
color: #404040;
|
|
61
|
+
font-size: 12px;
|
|
62
|
+
font-style: italic;
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
/* ######### */
|
|
66
|
+
/* GLOBALS */
|
|
67
|
+
* {
|
|
68
|
+
font-size: 14px;
|
|
69
|
+
outline: none;
|
|
70
|
+
box-sizing: border-box;
|
|
71
|
+
font-family: system-ui, -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, 'Open Sans',
|
|
72
|
+
'Helvetica Neue', sans-serif;
|
|
73
|
+
}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import * as React from 'react';
|
|
2
|
+
import { TsIcon } from '../TsIcon/TsIcon';
|
|
3
|
+
import { TsCheckboxProps } from './TsCheckbox.types';
|
|
4
|
+
import './TsCheckbox.css';
|
|
5
|
+
|
|
6
|
+
export const TsCheckbox = ({ caption, label, checked, disabled, onChange }: TsCheckboxProps) => {
|
|
7
|
+
// ########
|
|
8
|
+
// Handlers
|
|
9
|
+
const handleChange = () => !disabled && onChange(!checked);
|
|
10
|
+
|
|
11
|
+
// #########
|
|
12
|
+
// Rendering
|
|
13
|
+
return (
|
|
14
|
+
<div className={`ts-checkbox ${disabled ? 'ts-checkbox--disabled' : ''}`} onClick={handleChange}>
|
|
15
|
+
<div className="ts-checkbox-box">
|
|
16
|
+
<TsIcon name={checked ? 'check-square-filled' : 'square'} />
|
|
17
|
+
</div>
|
|
18
|
+
|
|
19
|
+
<div className={`ts-checkbox-container ${caption ? 'ts-checkbox-container--with-caption' : ''}`}>
|
|
20
|
+
<div className="ts-checkbox-label">{label}</div>
|
|
21
|
+
{caption && <div className="ts-checkbox-caption">{caption}</div>}
|
|
22
|
+
</div>
|
|
23
|
+
</div>
|
|
24
|
+
);
|
|
25
|
+
};
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { ArgsTable, Canvas, Meta, Story } from '@storybook/blocks';
|
|
3
|
+
import { TsCheckbox } from '../TsCheckbox';
|
|
4
|
+
|
|
5
|
+
<Meta title="Components/Checkbox" />
|
|
6
|
+
|
|
7
|
+
export const checkboxArgTypes = {
|
|
8
|
+
caption: {
|
|
9
|
+
control: 'text',
|
|
10
|
+
description: 'Caption of the checkbox.',
|
|
11
|
+
},
|
|
12
|
+
label: {
|
|
13
|
+
control: 'text',
|
|
14
|
+
description: 'Label of the checkbox.',
|
|
15
|
+
},
|
|
16
|
+
checked: {
|
|
17
|
+
control: 'boolean',
|
|
18
|
+
description: 'State of the checkbox.',
|
|
19
|
+
table: { defaultValue: { summary: 'false' } },
|
|
20
|
+
},
|
|
21
|
+
disabled: {
|
|
22
|
+
control: 'boolean',
|
|
23
|
+
description: 'Enable state of the checkbox.',
|
|
24
|
+
table: { defaultValue: { summary: 'false' } },
|
|
25
|
+
},
|
|
26
|
+
onChange: {
|
|
27
|
+
control: 'function',
|
|
28
|
+
description: 'The handler called when clicking on the checkbox.',
|
|
29
|
+
},
|
|
30
|
+
};
|
|
31
|
+
|
|
32
|
+
# Checkbox
|
|
33
|
+
|
|
34
|
+
Checkboxes are applied when users can select all, several, or none of the options from a given list.
|
|
35
|
+
|
|
36
|
+
## Overview
|
|
37
|
+
|
|
38
|
+
<Canvas>
|
|
39
|
+
<Story
|
|
40
|
+
name="Overview"
|
|
41
|
+
args={{
|
|
42
|
+
label: 'Lorem ipsum dolor sit amet, consectetur adipiscing elit',
|
|
43
|
+
caption:
|
|
44
|
+
'Auctor nisl justo, sed posuere est dignissim nec. Integer ultricies, metus ac imperdiet ullamcorper, est justo viverra nisl, in posuere dui urna eget quam.',
|
|
45
|
+
checked: false,
|
|
46
|
+
disabled: false,
|
|
47
|
+
}}
|
|
48
|
+
argTypes={checkboxArgTypes}
|
|
49
|
+
>
|
|
50
|
+
{args => <TsCheckbox {...args}>{args.children}</TsCheckbox>}
|
|
51
|
+
</Story>
|
|
52
|
+
</Canvas>
|
|
53
|
+
|
|
54
|
+
## Props
|
|
55
|
+
|
|
56
|
+
<ArgsTable story="Overview" of={TsCheckbox} />
|
package/src/index.ts
CHANGED