@charcoal-ui/styled 3.9.1 → 3.10.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/dist/index.cjs.js +177 -11
- package/dist/index.cjs.js.map +1 -1
- package/dist/index.d.ts +12 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.esm.js +174 -11
- package/dist/index.esm.js.map +1 -1
- package/dist/index.story.d.ts +0 -8
- package/dist/index.story.d.ts.map +1 -1
- package/dist/index.test.d.ts +5 -0
- package/dist/index.test.d.ts.map +1 -1
- package/dist/storyHelper.d.ts +2 -1
- package/dist/storyHelper.d.ts.map +1 -1
- package/dist/styles/assertiveRingCss.d.ts +2 -0
- package/dist/styles/assertiveRingCss.d.ts.map +1 -0
- package/dist/styles/disabledCss.d.ts +2 -0
- package/dist/styles/disabledCss.d.ts.map +1 -0
- package/dist/utils/CharcoalStyledTheme.d.ts +35 -0
- package/dist/utils/CharcoalStyledTheme.d.ts.map +1 -0
- package/dist/utils/addThemeUtils.d.ts +8 -0
- package/dist/utils/addThemeUtils.d.ts.map +1 -0
- package/dist/utils/gap.d.ts +7 -0
- package/dist/utils/gap.d.ts.map +1 -0
- package/dist/utils/helpers/SpacingType.d.ts +3 -0
- package/dist/utils/helpers/SpacingType.d.ts.map +1 -0
- package/dist/utils/helpers/pxIfNum.d.ts +2 -0
- package/dist/utils/helpers/pxIfNum.d.ts.map +1 -0
- package/dist/utils/margin.d.ts +11 -0
- package/dist/utils/margin.d.ts.map +1 -0
- package/dist/utils/padding.d.ts +11 -0
- package/dist/utils/padding.d.ts.map +1 -0
- package/dist/utils/typographyCss.d.ts +2 -0
- package/dist/utils/typographyCss.d.ts.map +1 -0
- package/package.json +8 -6
- package/src/__snapshots__/index.story.storyshot +88 -691
- package/src/__snapshots__/index.test.tsx.snap +177 -664
- package/src/index.story.tsx +81 -272
- package/src/index.test.tsx +55 -5
- package/src/index.ts +12 -1
- package/src/storyHelper.ts +8 -5
- package/src/styles/assertiveRingCss.ts +5 -0
- package/src/styles/disabledCss.ts +9 -0
- package/src/themeUtils.mdx +44 -0
- package/src/utils/CharcoalStyledTheme.ts +47 -0
- package/src/utils/addThemeUtils.ts +52 -0
- package/src/utils/gap.ts +28 -0
- package/src/utils/helpers/SpacingType.ts +3 -0
- package/src/utils/helpers/pxIfNum.ts +5 -0
- package/src/utils/margin.ts +58 -0
- package/src/utils/padding.ts +58 -0
- package/src/utils/typographyCss.ts +39 -0
package/dist/index.d.ts
CHANGED
|
@@ -8,6 +8,13 @@ export { defineThemeVariables } from './util';
|
|
|
8
8
|
export * from './SetThemeScript';
|
|
9
9
|
type Blank = null | undefined | false;
|
|
10
10
|
/**
|
|
11
|
+
* @deprecated
|
|
12
|
+
* 実行時のパフォーマンスが低い問題があります。
|
|
13
|
+
* ref. https://github.com/pixiv/charcoal/pull/377
|
|
14
|
+
*
|
|
15
|
+
* styled-components の theming 方法を推奨します。
|
|
16
|
+
* ref. https://styled-components.com/docs/advanced#theming
|
|
17
|
+
*
|
|
11
18
|
* `theme(o => [...])` の `theme` ユーティリティを構築する
|
|
12
19
|
*
|
|
13
20
|
* @param _styled - DEPRECATED: styled-components の `styled` そのものを渡すとそれを元に型推論ができる。が、型引数を渡す方が型推論が高速になりやすい
|
|
@@ -126,5 +133,9 @@ export declare function createTheme<T extends CharcoalAbstractTheme>(_styled?: T
|
|
|
126
133
|
export type ThemeProp<T> = ({ theme, }: {
|
|
127
134
|
theme: T | undefined;
|
|
128
135
|
}) => CSSObject | CSSObject[];
|
|
129
|
-
export
|
|
136
|
+
export { focusVisibleFocusRingCss } from './styles/focusVisibleFocusRingCss';
|
|
137
|
+
export { disabledCss } from './styles/disabledCss';
|
|
138
|
+
export { assertiveRingCss } from './styles/assertiveRingCss';
|
|
139
|
+
export type { CharcoalThemeUtils } from './utils/CharcoalStyledTheme';
|
|
140
|
+
export { addThemeUtils } from './utils/addThemeUtils';
|
|
130
141
|
//# sourceMappingURL=index.d.ts.map
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,qBAAqB,EAAE,MAAM,mBAAmB,CAAA;AACpE,OAAO,EAAE,qBAAqB,EAAE,MAAM,oBAAoB,CAAA;AAC1D,OAAO,EAAE,aAAa,EAAyC,MAAM,QAAQ,CAAA;AAC7E,OAAO,EAAE,QAAQ,EAAgB,MAAM,aAAa,CAAA;AAGpD,OAAO,EAAE,OAAO,IAAI,aAAa,EAAE,MAAM,iBAAiB,CAAA;AAC1D,OAAO,EACL,YAAY,EACZ,WAAW,EACX,aAAa,EACb,kBAAkB,EAClB,QAAQ,EACR,cAAc,EACd,eAAe,EACf,QAAQ,GACT,MAAM,UAAU,CAAA;AACjB,OAAO,EAAE,oBAAoB,EAAE,MAAM,QAAQ,CAAA;AAC7C,cAAc,kBAAkB,CAAA;AAEhC,KAAK,KAAK,GAAG,IAAI,GAAG,SAAS,GAAG,KAAK,CAAA;AAKrC
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,qBAAqB,EAAE,MAAM,mBAAmB,CAAA;AACpE,OAAO,EAAE,qBAAqB,EAAE,MAAM,oBAAoB,CAAA;AAC1D,OAAO,EAAE,aAAa,EAAyC,MAAM,QAAQ,CAAA;AAC7E,OAAO,EAAE,QAAQ,EAAgB,MAAM,aAAa,CAAA;AAGpD,OAAO,EAAE,OAAO,IAAI,aAAa,EAAE,MAAM,iBAAiB,CAAA;AAC1D,OAAO,EACL,YAAY,EACZ,WAAW,EACX,aAAa,EACb,kBAAkB,EAClB,QAAQ,EACR,cAAc,EACd,eAAe,EACf,QAAQ,GACT,MAAM,UAAU,CAAA;AACjB,OAAO,EAAE,oBAAoB,EAAE,MAAM,QAAQ,CAAA;AAC7C,cAAc,kBAAkB,CAAA;AAEhC,KAAK,KAAK,GAAG,IAAI,GAAG,SAAS,GAAG,KAAK,CAAA;AAKrC;;;;;;;;;;;;;;;;;;;;GAoBG;AACH,wBAAgB,WAAW,CAAC,CAAC,SAAS,qBAAqB,EACzD,OAAO,CAAC,EAAE,qBAAqB,CAAC,CAAC,CAAC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;OAMR,cAAc,QAAQ,GAAG,KAAK,CAAC,KACtD,UAAU,CAAC,CAAC,CAgChB;AAED,MAAM,MAAM,SAAS,CAAC,CAAC,IAAI,CAAC,EAC1B,KAAK,GACN,EAAE;IACD,KAAK,EAAE,CAAC,GAAG,SAAS,CAAA;CACrB,KAAK,SAAS,GAAG,SAAS,EAAE,CAAA;AAE7B,OAAO,EAAE,wBAAwB,EAAE,MAAM,mCAAmC,CAAA;AAC5E,OAAO,EAAE,WAAW,EAAE,MAAM,sBAAsB,CAAA;AAClD,OAAO,EAAE,gBAAgB,EAAE,MAAM,2BAA2B,CAAA;AAC5D,YAAY,EAAE,kBAAkB,EAAE,MAAM,6BAA6B,CAAA;AACrE,OAAO,EAAE,aAAa,EAAE,MAAM,uBAAuB,CAAA"}
|
package/dist/index.esm.js
CHANGED
|
@@ -48,8 +48,8 @@ function isSupportedEffect(effect) {
|
|
|
48
48
|
return ["hover", "press", "disabled"].includes(effect);
|
|
49
49
|
}
|
|
50
50
|
var variable = (value) => `var(${value})`;
|
|
51
|
-
function onEffectPseudo(effect,
|
|
52
|
-
return effect === "hover" ? { "&:hover": { [notDisabledSelector]:
|
|
51
|
+
function onEffectPseudo(effect, css9) {
|
|
52
|
+
return effect === "hover" ? { "&:hover": { [notDisabledSelector]: css9 } } : effect === "press" ? { "&:active": { [notDisabledSelector]: css9 } } : effect === "disabled" ? { [disabledSelector]: css9 } : unreachable(effect);
|
|
53
53
|
}
|
|
54
54
|
function withPrefixes(...parts) {
|
|
55
55
|
return parts.join("-");
|
|
@@ -416,18 +416,18 @@ var createOutlineColorCss = (theme) => (variant, modifiers) => {
|
|
|
416
416
|
}
|
|
417
417
|
});
|
|
418
418
|
};
|
|
419
|
-
var onFocus = (
|
|
419
|
+
var onFocus = (css9) => ({
|
|
420
420
|
[notDisabledSelector2]: {
|
|
421
421
|
"&:focus, &:active": {
|
|
422
422
|
outline: "none",
|
|
423
|
-
...
|
|
423
|
+
...css9
|
|
424
424
|
},
|
|
425
425
|
"&:focus:not(:focus-visible), &:active:not(:focus-visible)": {
|
|
426
426
|
outline: "none"
|
|
427
427
|
},
|
|
428
428
|
"&:focus-visible": {
|
|
429
429
|
outline: "none",
|
|
430
|
-
...
|
|
430
|
+
...css9
|
|
431
431
|
}
|
|
432
432
|
}
|
|
433
433
|
});
|
|
@@ -581,7 +581,7 @@ var createTypographyCss = (theme) => (size2, options = {}) => {
|
|
|
581
581
|
bold = false
|
|
582
582
|
} = options;
|
|
583
583
|
const descriptor = theme.typography.size[size2];
|
|
584
|
-
const
|
|
584
|
+
const margin2 = -halfLeading(descriptor);
|
|
585
585
|
function toCSS(context) {
|
|
586
586
|
return {
|
|
587
587
|
fontSize: px5(descriptor.fontSize),
|
|
@@ -596,11 +596,11 @@ var createTypographyCss = (theme) => (size2, options = {}) => {
|
|
|
596
596
|
display: "flow-root",
|
|
597
597
|
"&::before": {
|
|
598
598
|
...leadingCancel,
|
|
599
|
-
marginTop: px5(
|
|
599
|
+
marginTop: px5(margin2)
|
|
600
600
|
},
|
|
601
601
|
"&::after": {
|
|
602
602
|
...leadingCancel,
|
|
603
|
-
marginBottom: px5(
|
|
603
|
+
marginBottom: px5(margin2)
|
|
604
604
|
}
|
|
605
605
|
}
|
|
606
606
|
};
|
|
@@ -608,7 +608,7 @@ var createTypographyCss = (theme) => (size2, options = {}) => {
|
|
|
608
608
|
return createInternal({
|
|
609
609
|
toCSS,
|
|
610
610
|
context: !preserveHalfLeading ? {
|
|
611
|
-
cancelHalfLeadingPx:
|
|
611
|
+
cancelHalfLeadingPx: margin2
|
|
612
612
|
} : {}
|
|
613
613
|
});
|
|
614
614
|
};
|
|
@@ -697,8 +697,8 @@ var defineColorVariableCSS = (theme) => {
|
|
|
697
697
|
const colors2 = defineThemeVariables({ ...theme.color, ...borders })({ theme });
|
|
698
698
|
return toCSSVariables(colors2);
|
|
699
699
|
};
|
|
700
|
-
function toCSSVariables(
|
|
701
|
-
return Object.entries(
|
|
700
|
+
function toCSSVariables(css9) {
|
|
701
|
+
return Object.entries(css9).map(([varName, value]) => variableDefinition(varName, value.toString())).join(";");
|
|
702
702
|
}
|
|
703
703
|
var variableDefinition = (prop, value) => `${prop}: ${value}`;
|
|
704
704
|
|
|
@@ -875,6 +875,166 @@ var focusVisibleFocusRingCss = css2`
|
|
|
875
875
|
}
|
|
876
876
|
`;
|
|
877
877
|
|
|
878
|
+
// src/styles/disabledCss.ts
|
|
879
|
+
import { css as css3 } from "styled-components";
|
|
880
|
+
var disabledCss = css3`
|
|
881
|
+
:disabled,
|
|
882
|
+
[aria-disabled]:not([aria-disabled='false']) {
|
|
883
|
+
opacity: 0.32;
|
|
884
|
+
cursor: default;
|
|
885
|
+
}
|
|
886
|
+
`;
|
|
887
|
+
|
|
888
|
+
// src/styles/assertiveRingCss.ts
|
|
889
|
+
import { css as css4 } from "styled-components";
|
|
890
|
+
var assertiveRingCss = css4`
|
|
891
|
+
box-shadow: 0 0 0 4px rgba(255, 43, 0, 0.32);
|
|
892
|
+
`;
|
|
893
|
+
|
|
894
|
+
// src/utils/margin.ts
|
|
895
|
+
import { css as css5 } from "styled-components";
|
|
896
|
+
|
|
897
|
+
// src/utils/helpers/pxIfNum.ts
|
|
898
|
+
function pxIfNum(v) {
|
|
899
|
+
if (v === void 0)
|
|
900
|
+
return "";
|
|
901
|
+
if (typeof v === "number")
|
|
902
|
+
return `${v}px`;
|
|
903
|
+
return v;
|
|
904
|
+
}
|
|
905
|
+
|
|
906
|
+
// src/utils/margin.ts
|
|
907
|
+
function margin(arg1, arg2, arg3, arg4) {
|
|
908
|
+
return css5`
|
|
909
|
+
margin: ${pxIfNum(arg1)} ${pxIfNum(arg2)} ${pxIfNum(arg3)} ${pxIfNum(arg4)};
|
|
910
|
+
`;
|
|
911
|
+
}
|
|
912
|
+
function marginTop(v) {
|
|
913
|
+
return css5`
|
|
914
|
+
margin-top: ${pxIfNum(v)};
|
|
915
|
+
`;
|
|
916
|
+
}
|
|
917
|
+
function marginBottom(v) {
|
|
918
|
+
return css5`
|
|
919
|
+
margin-bottom: ${pxIfNum(v)};
|
|
920
|
+
`;
|
|
921
|
+
}
|
|
922
|
+
function marginLeft(v) {
|
|
923
|
+
return css5`
|
|
924
|
+
margin-left: ${pxIfNum(v)};
|
|
925
|
+
`;
|
|
926
|
+
}
|
|
927
|
+
function marginRight(v) {
|
|
928
|
+
return css5`
|
|
929
|
+
margin-right: ${pxIfNum(v)};
|
|
930
|
+
`;
|
|
931
|
+
}
|
|
932
|
+
|
|
933
|
+
// src/utils/padding.ts
|
|
934
|
+
import { css as css6 } from "styled-components";
|
|
935
|
+
function padding(arg1, arg2, arg3, arg4) {
|
|
936
|
+
return css6`
|
|
937
|
+
padding: ${arg1}px ${pxIfNum(arg2)} ${pxIfNum(arg3)} ${pxIfNum(arg4)};
|
|
938
|
+
`;
|
|
939
|
+
}
|
|
940
|
+
function paddingTop(v) {
|
|
941
|
+
return css6`
|
|
942
|
+
padding-top: ${v}px;
|
|
943
|
+
`;
|
|
944
|
+
}
|
|
945
|
+
function paddingBottom(v) {
|
|
946
|
+
return css6`
|
|
947
|
+
padding-bottom: ${v}px;
|
|
948
|
+
`;
|
|
949
|
+
}
|
|
950
|
+
function paddingLeft(v) {
|
|
951
|
+
return css6`
|
|
952
|
+
padding-left: ${v}px;
|
|
953
|
+
`;
|
|
954
|
+
}
|
|
955
|
+
function paddingRight(v) {
|
|
956
|
+
return css6`
|
|
957
|
+
padding-right: ${v}px;
|
|
958
|
+
`;
|
|
959
|
+
}
|
|
960
|
+
|
|
961
|
+
// src/utils/gap.ts
|
|
962
|
+
import { css as css7 } from "styled-components";
|
|
963
|
+
function gap(v1, v2) {
|
|
964
|
+
return css7`
|
|
965
|
+
gap: ${v1}px ${pxIfNum(v2)};
|
|
966
|
+
`;
|
|
967
|
+
}
|
|
968
|
+
function rowGap(v) {
|
|
969
|
+
return css7`
|
|
970
|
+
row-gap: ${v}px;
|
|
971
|
+
`;
|
|
972
|
+
}
|
|
973
|
+
function columnGap(v) {
|
|
974
|
+
return css7`
|
|
975
|
+
column-gap: ${v}px;
|
|
976
|
+
`;
|
|
977
|
+
}
|
|
978
|
+
|
|
979
|
+
// src/utils/typographyCss.ts
|
|
980
|
+
import { css as css8 } from "styled-components";
|
|
981
|
+
var boldCss = css8`
|
|
982
|
+
font-weight: bold;
|
|
983
|
+
`;
|
|
984
|
+
var removeHalfLeadingCss = css8`
|
|
985
|
+
&::before {
|
|
986
|
+
display: block;
|
|
987
|
+
width: 0;
|
|
988
|
+
height: 0;
|
|
989
|
+
content: '';
|
|
990
|
+
margin-top: -4px;
|
|
991
|
+
}
|
|
992
|
+
|
|
993
|
+
&::after {
|
|
994
|
+
display: block;
|
|
995
|
+
width: 0;
|
|
996
|
+
height: 0;
|
|
997
|
+
content: '';
|
|
998
|
+
margin-bottom: -4px;
|
|
999
|
+
}
|
|
1000
|
+
`;
|
|
1001
|
+
function typography2(size2, bold = false, preserveHalfLeading = false) {
|
|
1002
|
+
const cssObj = css8`
|
|
1003
|
+
font-size: ${size2}px;
|
|
1004
|
+
line-height: ${size2 + 8}px;
|
|
1005
|
+
display: flow-root;
|
|
1006
|
+
${bold === true && boldCss}
|
|
1007
|
+
${preserveHalfLeading !== true && removeHalfLeadingCss}
|
|
1008
|
+
`;
|
|
1009
|
+
return cssObj;
|
|
1010
|
+
}
|
|
1011
|
+
|
|
1012
|
+
// src/utils/addThemeUtils.ts
|
|
1013
|
+
function addThemeUtils(theme) {
|
|
1014
|
+
return {
|
|
1015
|
+
...theme,
|
|
1016
|
+
utils: {
|
|
1017
|
+
margin,
|
|
1018
|
+
marginTop,
|
|
1019
|
+
marginLeft,
|
|
1020
|
+
marginBottom,
|
|
1021
|
+
marginRight,
|
|
1022
|
+
padding,
|
|
1023
|
+
paddingTop,
|
|
1024
|
+
paddingLeft,
|
|
1025
|
+
paddingBottom,
|
|
1026
|
+
paddingRight,
|
|
1027
|
+
gap,
|
|
1028
|
+
rowGap,
|
|
1029
|
+
columnGap,
|
|
1030
|
+
typography: typography2,
|
|
1031
|
+
focusVisibleFocusRingCss,
|
|
1032
|
+
assertiveRingCss,
|
|
1033
|
+
disabledCss
|
|
1034
|
+
}
|
|
1035
|
+
};
|
|
1036
|
+
}
|
|
1037
|
+
|
|
878
1038
|
// src/index.ts
|
|
879
1039
|
var nonBlank = (value) => isPresent(value) && value !== false;
|
|
880
1040
|
function createTheme(_styled) {
|
|
@@ -896,8 +1056,11 @@ function createTheme(_styled) {
|
|
|
896
1056
|
export {
|
|
897
1057
|
SetThemeScript,
|
|
898
1058
|
TokenInjector,
|
|
1059
|
+
addThemeUtils,
|
|
1060
|
+
assertiveRingCss,
|
|
899
1061
|
createTheme,
|
|
900
1062
|
defineThemeVariables,
|
|
1063
|
+
disabledCss,
|
|
901
1064
|
focusVisibleFocusRingCss,
|
|
902
1065
|
getThemeSync,
|
|
903
1066
|
makeSetThemeScriptCode,
|