@kvdbil/components 11.10.0 → 11.10.2
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/README.md
CHANGED
|
@@ -1,3 +1,40 @@
|
|
|
1
|
-
|
|
1
|
+
# Kvdbil Components
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
The purpose of this repo is to have a collection of reusable components to be used in our other repos.
|
|
4
|
+
The primary goal is to have most shared components here for both the Kvd.se and Fleet-manager-client repos (not Cargo).
|
|
5
|
+
|
|
6
|
+
The component library is published in public npm repo https://www.npmjs.com/package/@kvdbil/components where we can find the lates version tag.
|
|
7
|
+
|
|
8
|
+
All changes are done using conventional commits so CHANGELOG.md is generated automatically.
|
|
9
|
+
|
|
10
|
+
## Explore kvdbil components, theme (e.g. colors), typography and icons
|
|
11
|
+
|
|
12
|
+
We use Storybook to display all the components, icons, theme and more. This can be found here:
|
|
13
|
+
|
|
14
|
+
- locally - `yarn dev` or `yarn start`
|
|
15
|
+
- deployed last version - http://kvdbil-components.development.kvd.se
|
|
16
|
+
|
|
17
|
+
## Work with kvdbil-components
|
|
18
|
+
|
|
19
|
+
All changes that affect all shared things in this repo must be done using conventional commits (https://www.conventionalcommits.org).
|
|
20
|
+
All commit messages are validated by `commitlint` (https://github.com/conventional-changelog/commitlint). Examples for version bumping:
|
|
21
|
+
|
|
22
|
+
- bugfix (e.g. styling component fix) - example: `git commit -m "fix(KDEV-1337): fixed padding issue for Button"`<br>After merge to master a version be bumped e.g. from 5.2.2 to 5.2.3
|
|
23
|
+
|
|
24
|
+
- new feature (e.g adding new component or extending existing one) - example: `git commit -m "feat(KDEV-1338): Button component has been added"`<br>After merge to master a version be bumped e.g. from 5.2.2 to 5.3.0
|
|
25
|
+
|
|
26
|
+
- BREAKING CHANGE (e.g removing required prop from component)<br>
|
|
27
|
+
Example: `git commit -m "feat(KDEV-1339): removed onClick prop from Button"` and next add a commit message footer with `git commit --amend`
|
|
28
|
+
<br>
|
|
29
|
+
After merge to master a version be bumped e.g. from 5.2.2 to 6.0.0
|
|
30
|
+
<br>
|
|
31
|
+
Should look something like that:
|
|
32
|
+
|
|
33
|
+
> feat(KDEV-1339): removed onClick prop from Button
|
|
34
|
+
>
|
|
35
|
+
> BREAKING CHANGE: The onClick prop in Button component has been removed
|
|
36
|
+
|
|
37
|
+
|
|
38
|
+
For a changes that do not affect any shared components we can use:
|
|
39
|
+
|
|
40
|
+
- `git commit -m "docs(KDEV-1222): updated readme file"`
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("react"),
|
|
2
|
-
font-family: ${({theme:
|
|
3
|
-
font-size: ${({size:
|
|
4
|
-
font-weight: ${({theme:
|
|
1
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("react"),r=require("styled-components"),o=require("../../icons/components/CloseIcon.js"),t=require("./styles.js");function l(f){return f&&typeof f=="object"&&"default"in f?f:{default:f}}var i=l(e),a=l(r);const n={smaller:"0.25rem 1rem",small:"0.25rem 1rem",regular:"0.25rem 1rem",large:"0.5rem 1rem"},s=a.default.div`
|
|
2
|
+
font-family: ${({theme:f})=>f.typography.fontBaseFamily};
|
|
3
|
+
font-size: ${({size:f})=>t.getFontSize(f)};
|
|
4
|
+
font-weight: ${({theme:f})=>f.typography.fontBaseBoldWeight};
|
|
5
5
|
line-height: 1.25;
|
|
6
6
|
letter-spacing: 0.1px;
|
|
7
7
|
display: inline-flex;
|
|
@@ -14,33 +14,35 @@
|
|
|
14
14
|
border-style: solid;
|
|
15
15
|
border-color: ${t.getBorderColor};
|
|
16
16
|
border-radius: 1.293rem;
|
|
17
|
-
padding: ${({isDeletable:
|
|
17
|
+
padding: ${({size:f,isDeletable:v})=>v?"0 0.5rem 0 1rem":n[f]};
|
|
18
18
|
transition: color 0.3s ease, background-color 0.3s ease, border 0.3s ease;
|
|
19
19
|
|
|
20
|
-
${
|
|
21
|
-
border-color: ${t.getHoverBorderColor(
|
|
22
|
-
background-color: ${t.getHoverBackgroundColor(
|
|
23
|
-
color: ${t.getHoverColor(
|
|
20
|
+
${f=>!f.isDisabled&&f.isClickable&&` &:hover {
|
|
21
|
+
border-color: ${t.getHoverBorderColor(f)};
|
|
22
|
+
background-color: ${t.getHoverBackgroundColor(f)};
|
|
23
|
+
color: ${t.getHoverColor(f)};
|
|
24
24
|
} &:active {
|
|
25
|
-
background-color: ${t.getActiveBackgroundColor(
|
|
26
|
-
border-color: ${t.getActiveBorderColor(
|
|
27
|
-
color: ${t.getActiveColor(
|
|
25
|
+
background-color: ${t.getActiveBackgroundColor(f)};
|
|
26
|
+
border-color: ${t.getActiveBorderColor(f)};
|
|
27
|
+
color: ${t.getActiveColor(f)};
|
|
28
28
|
}`}
|
|
29
|
-
`,
|
|
29
|
+
`,c=a.default.span`
|
|
30
30
|
display: flex;
|
|
31
31
|
align-items: center;
|
|
32
32
|
justify-content: center;
|
|
33
33
|
text-align: center;
|
|
34
34
|
line-height: 1.5;
|
|
35
|
-
`,
|
|
35
|
+
`,d=a.default.span`
|
|
36
36
|
margin-right: 0.625rem;
|
|
37
37
|
display: flex;
|
|
38
38
|
align-items: center;
|
|
39
|
-
`,
|
|
39
|
+
`,u=a.default.span`
|
|
40
40
|
display: flex;
|
|
41
41
|
align-items: center;
|
|
42
42
|
cursor: ${t.getCursorType};
|
|
43
43
|
padding: 0.5rem;
|
|
44
|
+
margin-left: 0.25rem;
|
|
45
|
+
margin-right: -0.25rem;
|
|
44
46
|
position: relative;
|
|
45
47
|
z-index: 2;
|
|
46
48
|
&:before {
|
|
@@ -65,4 +67,4 @@
|
|
|
65
67
|
&:hover:before {
|
|
66
68
|
opacity: 1;
|
|
67
69
|
}
|
|
68
|
-
`,
|
|
70
|
+
`,g=({color:f="primary",children:v,component:x="div",isDisabled:b,onClick:h,size:B="regular",prefix:y,onDelete:m,variant:C="solid",...z})=>{const p=Boolean(h&&!b),$=Boolean(m&&!b),D=Boolean(y);return i.default.createElement(s,{...z,role:p?"button":void 0,onClick:p?h:void 0,tabIndex:p?0:void 0,as:p?"button":x,color:f,isDisabled:b,size:B,isClickable:p,isDeletable:$,variant:C,hasPrefix:D},i.default.createElement(c,null,y&&i.default.createElement(d,{className:"prefix"},y),v,m&&i.default.createElement(u,{role:"button",onClick:$?k=>{k.stopPropagation(),m==null||m(k)}:void 0,color:f,variant:C,isClickable:p,isDisabled:b,isDeletable:!0,size:"regular"},i.default.createElement(o.default,null))))};exports.Chip=g,exports.default=g;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.getActiveBackgroundColor=({color:t,variant:o,isDisabled:r,theme:l})=>r?"transparent":t==="neutralLight"?l.colors.background.light:o==="solid"?l.colors[t].light:"transparent",exports.getActiveBorderColor=({variant:t,color:o,theme:r})=>o==="neutralLight"?{solid:r.colors.background.light,flat:"transparent",outline:r.colors.background.light}[t]:{solid:r.colors[o].light,flat:"transparent",outline:r.colors[o].light}[t],exports.getActiveColor=({variant:t,color:o,theme:r})=>o==="neutralLight"?r.colors.text.dark:t==="solid"?r.colors.text.light:r.colors[o].light,exports.getBackgroundColor=({isDisabled:t,variant:o,color:r,theme:l})=>t?l.colors.gray.light5:r==="neutralLight"?{solid:l.colors.background.gray,flat:l.colors.background.light,outline:"transparent"}[o]:{solid:l.colors[r].main,flat:l.colors.background.light,outline:"transparent"}[o],exports.getBorderColor=({color:t,isDisabled:o,variant:r,theme:l})=>o?l.colors.gray.light5:t==="neutralLight"?{solid:"transparent",flat:"transparent",outline:l.colors.text.disabled}[r]:{solid:l.colors[t].main,flat:"transparent",outline:l.colors[t].main}[r],exports.getColor=({isDisabled:t,variant:o,color:r,theme:l})=>t?l.colors.text.disabled:r==="neutralLight"?o==="outline"?l.colors.text.disabled:l.colors.text.dark:{solid:l.colors.text.light,flat:l.colors[r].main,outline:l.colors[r].main}[o],exports.getCursorType=({isDisabled:t,isClickable:o,isDeletable:r})=>t?"not-allowed":o||r?"pointer":"auto",exports.getFontSize=(t="smaller")=>({smaller:"0.625rem",small:"0.75rem",regular:"1rem",large:"
|
|
1
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.getActiveBackgroundColor=({color:t,variant:o,isDisabled:r,theme:l})=>r?"transparent":t==="neutralLight"?l.colors.background.light:o==="solid"?l.colors[t].light:"transparent",exports.getActiveBorderColor=({variant:t,color:o,theme:r})=>o==="neutralLight"?{solid:r.colors.background.light,flat:"transparent",outline:r.colors.background.light}[t]:{solid:r.colors[o].light,flat:"transparent",outline:r.colors[o].light}[t],exports.getActiveColor=({variant:t,color:o,theme:r})=>o==="neutralLight"?r.colors.text.dark:t==="solid"?r.colors.text.light:r.colors[o].light,exports.getBackgroundColor=({isDisabled:t,variant:o,color:r,theme:l})=>t?l.colors.gray.light5:r==="neutralLight"?{solid:l.colors.background.gray,flat:l.colors.background.light,outline:"transparent"}[o]:{solid:l.colors[r].main,flat:l.colors.background.light,outline:"transparent"}[o],exports.getBorderColor=({color:t,isDisabled:o,variant:r,theme:l})=>o?l.colors.gray.light5:t==="neutralLight"?{solid:"transparent",flat:"transparent",outline:l.colors.text.disabled}[r]:{solid:l.colors[t].main,flat:"transparent",outline:l.colors[t].main}[r],exports.getColor=({isDisabled:t,variant:o,color:r,theme:l})=>t?l.colors.text.disabled:r==="neutralLight"?o==="outline"?l.colors.text.disabled:l.colors.text.dark:{solid:l.colors.text.light,flat:l.colors[r].main,outline:l.colors[r].main}[o],exports.getCursorType=({isDisabled:t,isClickable:o,isDeletable:r})=>t?"not-allowed":o||r?"pointer":"auto",exports.getFontSize=(t="smaller")=>({smaller:"0.625rem",small:"0.75rem",regular:"1rem",large:"1rem"})[t],exports.getHoverBackgroundColor=({variant:t,color:o,theme:r})=>o==="neutralLight"?{solid:r.colors.gray.light4,flat:r.colors.background.light,outline:"transparent"}[t]:{solid:r.colors[o].dark,flat:r.colors.background.light,outline:"transparent"}[t],exports.getHoverBorderColor=({variant:t,color:o,theme:r})=>o==="neutralLight"?{solid:r.colors.gray.light4,flat:"transparent",outline:r.colors.text.dark}[t]:{solid:r.colors[o].dark,flat:"transparent",outline:r.colors[o].dark}[t],exports.getHoverColor=({variant:t,color:o,theme:r})=>o==="neutralLight"?r.colors.text.dark:{solid:r.colors.text.light,flat:r.colors[o].dark,outline:r.colors[o].dark}[t],exports.getSufixHoverBackgroundColor=({variant:t,color:o,isClickable:r,isDisabled:l,theme:e})=>l?e.colors.gray.light5:o==="neutralLight"?{solid:e.colors.gray.light2,flat:e.colors.gray.light4,outline:e.colors.gray.light4}[t]:t==="solid"?r?e.colors[o].darker:e.colors[o].dark:e.colors.background.gray;
|
|
@@ -1,11 +1,11 @@
|
|
|
1
|
-
import
|
|
1
|
+
import r from"react";import l from"styled-components";import C from"../../icons/components/CloseIcon.js";import{getFontSize as $,getCursorType as m,getBackgroundColor as x,getColor as k,getBorderColor as B,getHoverBorderColor as z,getHoverBackgroundColor as E,getHoverColor as j,getActiveBackgroundColor as u,getActiveBorderColor as H,getActiveColor as I,getSufixHoverBackgroundColor as w}from"./styles.js";const A={smaller:"0.25rem 1rem",small:"0.25rem 1rem",regular:"0.25rem 1rem",large:"0.5rem 1rem"},P=l.div`
|
|
2
2
|
font-family: ${({theme:e})=>e.typography.fontBaseFamily};
|
|
3
3
|
font-size: ${({size:e})=>$(e)};
|
|
4
4
|
font-weight: ${({theme:e})=>e.typography.fontBaseBoldWeight};
|
|
5
5
|
line-height: 1.25;
|
|
6
6
|
letter-spacing: 0.1px;
|
|
7
7
|
display: inline-flex;
|
|
8
|
-
cursor: ${
|
|
8
|
+
cursor: ${m};
|
|
9
9
|
align-items: center;
|
|
10
10
|
background: ${x};
|
|
11
11
|
color: ${k};
|
|
@@ -14,33 +14,35 @@ import t from"react";import i from"styled-components";import C from"../../icons/
|
|
|
14
14
|
border-style: solid;
|
|
15
15
|
border-color: ${B};
|
|
16
16
|
border-radius: 1.293rem;
|
|
17
|
-
padding: ${({isDeletable:
|
|
17
|
+
padding: ${({size:e,isDeletable:i})=>i?"0 0.5rem 0 1rem":A[e]};
|
|
18
18
|
transition: color 0.3s ease, background-color 0.3s ease, border 0.3s ease;
|
|
19
19
|
|
|
20
20
|
${e=>!e.isDisabled&&e.isClickable&&` &:hover {
|
|
21
|
-
border-color: ${
|
|
22
|
-
background-color: ${
|
|
23
|
-
color: ${
|
|
21
|
+
border-color: ${z(e)};
|
|
22
|
+
background-color: ${E(e)};
|
|
23
|
+
color: ${j(e)};
|
|
24
24
|
} &:active {
|
|
25
|
-
background-color: ${
|
|
25
|
+
background-color: ${u(e)};
|
|
26
26
|
border-color: ${H(e)};
|
|
27
27
|
color: ${I(e)};
|
|
28
28
|
}`}
|
|
29
|
-
`,
|
|
29
|
+
`,S=l.span`
|
|
30
30
|
display: flex;
|
|
31
31
|
align-items: center;
|
|
32
32
|
justify-content: center;
|
|
33
33
|
text-align: center;
|
|
34
34
|
line-height: 1.5;
|
|
35
|
-
`,
|
|
35
|
+
`,F=l.span`
|
|
36
36
|
margin-right: 0.625rem;
|
|
37
37
|
display: flex;
|
|
38
38
|
align-items: center;
|
|
39
|
-
`,
|
|
39
|
+
`,W=l.span`
|
|
40
40
|
display: flex;
|
|
41
41
|
align-items: center;
|
|
42
|
-
cursor: ${
|
|
42
|
+
cursor: ${m};
|
|
43
43
|
padding: 0.5rem;
|
|
44
|
+
margin-left: 0.25rem;
|
|
45
|
+
margin-right: -0.25rem;
|
|
44
46
|
position: relative;
|
|
45
47
|
z-index: 2;
|
|
46
48
|
&:before {
|
|
@@ -58,11 +60,11 @@ import t from"react";import i from"styled-components";import C from"../../icons/
|
|
|
58
60
|
}
|
|
59
61
|
|
|
60
62
|
&:active:before {
|
|
61
|
-
background-color: ${
|
|
63
|
+
background-color: ${u};
|
|
62
64
|
opacity: 1;
|
|
63
65
|
}
|
|
64
66
|
|
|
65
67
|
&:hover:before {
|
|
66
68
|
opacity: 1;
|
|
67
69
|
}
|
|
68
|
-
`,
|
|
70
|
+
`,f=({color:e="primary",children:i,component:b="div",isDisabled:t,onClick:c,size:p="regular",prefix:a,onDelete:n,variant:s="solid",...y})=>{const o=Boolean(c&&!t),d=Boolean(n&&!t),h=Boolean(a),v=g=>{g.stopPropagation(),n==null||n(g)};return r.createElement(P,{...y,role:o?"button":void 0,onClick:o?c:void 0,tabIndex:o?0:void 0,as:o?"button":b,color:e,isDisabled:t,size:p,isClickable:o,isDeletable:d,variant:s,hasPrefix:h},r.createElement(S,null,a&&r.createElement(F,{className:"prefix"},a),i,n&&r.createElement(W,{role:"button",onClick:d?v:void 0,color:e,variant:s,isClickable:o,isDisabled:t,isDeletable:!0,size:"regular"},r.createElement(C,null))))};export{f as Chip,f as default};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
const i=(t="smaller")=>({smaller:"0.625rem",small:"0.75rem",regular:"1rem",large:"
|
|
1
|
+
const i=(t="smaller")=>({smaller:"0.625rem",small:"0.75rem",regular:"1rem",large:"1rem"})[t],a=({isDisabled:t,variant:o,color:r,theme:l})=>t?l.colors.gray.light5:r==="neutralLight"?{solid:l.colors.background.gray,flat:l.colors.background.light,outline:"transparent"}[o]:{solid:l.colors[r].main,flat:l.colors.background.light,outline:"transparent"}[o],u=({isDisabled:t,variant:o,color:r,theme:l})=>t?l.colors.text.disabled:r==="neutralLight"?o==="outline"?l.colors.text.disabled:l.colors.text.dark:{solid:l.colors.text.light,flat:l.colors[r].main,outline:l.colors[r].main}[o],c=({color:t,isDisabled:o,variant:r,theme:l})=>o?l.colors.gray.light5:t==="neutralLight"?{solid:"transparent",flat:"transparent",outline:l.colors.text.disabled}[r]:{solid:l.colors[t].main,flat:"transparent",outline:l.colors[t].main}[r],g=({isDisabled:t,isClickable:o,isDeletable:r})=>t?"not-allowed":o||r?"pointer":"auto",e=({variant:t,color:o,theme:r})=>o==="neutralLight"?{solid:r.colors.gray.light4,flat:r.colors.background.light,outline:"transparent"}[t]:{solid:r.colors[o].dark,flat:r.colors.background.light,outline:"transparent"}[t],d=({variant:t,color:o,theme:r})=>o==="neutralLight"?{solid:r.colors.gray.light4,flat:"transparent",outline:r.colors.text.dark}[t]:{solid:r.colors[o].dark,flat:"transparent",outline:r.colors[o].dark}[t],f=({variant:t,color:o,theme:r})=>o==="neutralLight"?r.colors.text.dark:{solid:r.colors.text.light,flat:r.colors[o].dark,outline:r.colors[o].dark}[t],k=({variant:t,color:o,isClickable:r,isDisabled:l,theme:n})=>l?n.colors.gray.light5:o==="neutralLight"?{solid:n.colors.gray.light2,flat:n.colors.gray.light4,outline:n.colors.gray.light4}[t]:t==="solid"?r?n.colors[o].darker:n.colors[o].dark:n.colors.background.gray,C=({color:t,variant:o,isDisabled:r,theme:l})=>r?"transparent":t==="neutralLight"?l.colors.background.light:o==="solid"?l.colors[t].light:"transparent",L=({variant:t,color:o,theme:r})=>o==="neutralLight"?{solid:r.colors.background.light,flat:"transparent",outline:r.colors.background.light}[t]:{solid:r.colors[o].light,flat:"transparent",outline:r.colors[o].light}[t],p=({variant:t,color:o,theme:r})=>o==="neutralLight"?r.colors.text.dark:t==="solid"?r.colors.text.light:r.colors[o].light;export{C as getActiveBackgroundColor,L as getActiveBorderColor,p as getActiveColor,a as getBackgroundColor,c as getBorderColor,u as getColor,g as getCursorType,i as getFontSize,e as getHoverBackgroundColor,d as getHoverBorderColor,f as getHoverColor,k as getSufixHoverBackgroundColor};
|
package/package.json
CHANGED