@wordpress/primitives 3.35.0 → 3.36.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/CHANGELOG.md CHANGED
@@ -2,6 +2,8 @@
2
2
 
3
3
  ## Unreleased
4
4
 
5
+ ## 3.36.0 (2023-07-20)
6
+
5
7
  ## 3.35.0 (2023-07-05)
6
8
 
7
9
  ## 3.34.0 (2023-06-23)
@@ -73,6 +73,8 @@ var _reactNativeSvg = require("react-native-svg");
73
73
 
74
74
  var _reactNative = require("react-native");
75
75
 
76
+ var _compose = require("@wordpress/compose");
77
+
76
78
  var _style = _interopRequireDefault(require("./style.scss"));
77
79
 
78
80
  /**
@@ -97,9 +99,9 @@ const SVG = ({
97
99
  animated = false,
98
100
  ...props
99
101
  }) => {
100
- const colorScheme = props.colorScheme || 'light';
102
+ const colorScheme = (0, _compose.usePreferredColorScheme)();
101
103
  const stylesFromClasses = className.split(' ').map(element => _style.default[element]).filter(Boolean);
102
- const defaultStyle = isPressed ? _style.default['is-pressed'] : _style.default['components-toolbar__control-' + colorScheme];
104
+ const defaultStyle = isPressed ? _style.default[`is-pressed--${colorScheme}`] : _style.default['components-toolbar__control-' + colorScheme];
103
105
  const propStyle = Array.isArray(props.style) ? props.style.reduce((acc, el) => {
104
106
  return { ...acc,
105
107
  ...el
@@ -1 +1 @@
1
- {"version":3,"sources":["@wordpress/primitives/src/svg/index.native.js"],"names":["AnimatedSvg","Animated","createAnimatedComponent","props","ref","SVG","className","isPressed","animated","colorScheme","stylesFromClasses","split","map","element","styles","filter","Boolean","defaultStyle","propStyle","Array","isArray","style","reduce","acc","el","styleValues","Object","assign","appliedProps","SvgWrapper","Svg","color"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AASA;;AANA;;AACA;;AAUA;;AAdA;AACA;AACA;;AAIA;AACA;AACA;;AAGA;AACA;AACA;AAgBA,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,CAACP,KAAb,CAAmBU,KAF1B;AAGC,IAAA,MAAM,EAAC,MAHR;AAIC,IAAA,KAAK,EAAC,MAJP;AAAA,OAKMH;AALN,IADD;AASA,CAvCM","sourcesContent":["/**\n * External dependencies\n */\nimport { Svg } from 'react-native-svg';\nimport { Animated } from 'react-native';\n\n/**\n * WordPress dependencies\n */\nimport { forwardRef } from '@wordpress/element';\n\n/**\n * Internal dependencies\n */\nimport styles from './style.scss';\n\nexport {\n\tCircle,\n\tG,\n\tPath,\n\tPolygon,\n\tRect,\n\tDefs,\n\tRadialGradient,\n\tLinearGradient,\n\tStop,\n\tLine,\n} from 'react-native-svg';\n\nconst AnimatedSvg = Animated.createAnimatedComponent(\n\tforwardRef( ( props, ref ) => <Svg ref={ ref } { ...props } /> )\n);\n\nexport const SVG = ( {\n\tclassName = '',\n\tisPressed,\n\tanimated = false,\n\t...props\n} ) => {\n\tconst colorScheme = props.colorScheme || 'light';\n\tconst stylesFromClasses = className\n\t\t.split( ' ' )\n\t\t.map( ( element ) => styles[ element ] )\n\t\t.filter( Boolean );\n\tconst defaultStyle = isPressed\n\t\t? styles[ 'is-pressed' ]\n\t\t: styles[ 'components-toolbar__control-' + colorScheme ];\n\tconst propStyle = Array.isArray( props.style )\n\t\t? props.style.reduce( ( acc, el ) => {\n\t\t\t\treturn { ...acc, ...el };\n\t\t }, {} )\n\t\t: props.style;\n\tconst styleValues = Object.assign(\n\t\t{},\n\t\tdefaultStyle,\n\t\tpropStyle,\n\t\t...stylesFromClasses\n\t);\n\n\tconst appliedProps = { ...props, style: styleValues };\n\n\tconst SvgWrapper = animated ? AnimatedSvg : Svg;\n\n\treturn (\n\t\t<SvgWrapper\n\t\t\t// We want to re-render when style color is changed.\n\t\t\tkey={ appliedProps.style.color }\n\t\t\theight=\"100%\"\n\t\t\twidth=\"100%\"\n\t\t\t{ ...appliedProps }\n\t\t/>\n\t);\n};\n"]}
1
+ {"version":3,"sources":["@wordpress/primitives/src/svg/index.native.js"],"names":["AnimatedSvg","Animated","createAnimatedComponent","props","ref","SVG","className","isPressed","animated","colorScheme","stylesFromClasses","split","map","element","styles","filter","Boolean","defaultStyle","propStyle","Array","isArray","style","reduce","acc","el","styleValues","Object","assign","appliedProps","SvgWrapper","Svg","color"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AASA;;AANA;;AACA;;AAMA;;AAKA;;AAfA;AACA;AACA;;AAIA;AACA;AACA;;AAIA;AACA;AACA;AAgBA,MAAMA,WAAW,GAAGC,sBAASC,uBAAT,CACnB,yBAAY,CAAEC,KAAF,EAASC,GAAT,KAAkB,4BAAC,mBAAD;AAAK,EAAA,GAAG,EAAGA,GAAX;AAAA,KAAsBD;AAAtB,EAA9B,CADmB,CAApB;;AAIO,MAAME,GAAG,GAAG,CAAE;AACpBC,EAAAA,SAAS,GAAG,EADQ;AAEpBC,EAAAA,SAFoB;AAGpBC,EAAAA,QAAQ,GAAG,KAHS;AAIpB,KAAGL;AAJiB,CAAF,KAKZ;AACN,QAAMM,WAAW,GAAG,uCAApB;AACA,QAAMC,iBAAiB,GAAGJ,SAAS,CACjCK,KADwB,CACjB,GADiB,EAExBC,GAFwB,CAEjBC,OAAF,IAAeC,eAAQD,OAAR,CAFI,EAGxBE,MAHwB,CAGhBC,OAHgB,CAA1B;AAIA,QAAMC,YAAY,GAAGV,SAAS,GAC3BO,eAAS,eAAeL,WAAa,EAArC,CAD2B,GAE3BK,eAAQ,iCAAiCL,WAAzC,CAFH;AAGA,QAAMS,SAAS,GAAGC,KAAK,CAACC,OAAN,CAAejB,KAAK,CAACkB,KAArB,IACflB,KAAK,CAACkB,KAAN,CAAYC,MAAZ,CAAoB,CAAEC,GAAF,EAAOC,EAAP,KAAe;AACnC,WAAO,EAAE,GAAGD,GAAL;AAAU,SAAGC;AAAb,KAAP;AACC,GAFD,EAEG,EAFH,CADe,GAIfrB,KAAK,CAACkB,KAJT;AAKA,QAAMI,WAAW,GAAGC,MAAM,CAACC,MAAP,CACnB,EADmB,EAEnBV,YAFmB,EAGnBC,SAHmB,EAInB,GAAGR,iBAJgB,CAApB;AAOA,QAAMkB,YAAY,GAAG,EAAE,GAAGzB,KAAL;AAAYkB,IAAAA,KAAK,EAAEI;AAAnB,GAArB;AAEA,QAAMI,UAAU,GAAGrB,QAAQ,GAAGR,WAAH,GAAiB8B,mBAA5C;AAEA,SACC,4BAAC,UAAD,CACC;AADD;AAEC,IAAA,GAAG,EAAGF,YAAY,CAACP,KAAb,CAAmBU,KAF1B;AAGC,IAAA,MAAM,EAAC,MAHR;AAIC,IAAA,KAAK,EAAC,MAJP;AAAA,OAKMH;AALN,IADD;AASA,CAvCM","sourcesContent":["/**\n * External dependencies\n */\nimport { Svg } from 'react-native-svg';\nimport { Animated } from 'react-native';\n\n/**\n * WordPress dependencies\n */\nimport { forwardRef } from '@wordpress/element';\nimport { usePreferredColorScheme } from '@wordpress/compose';\n\n/**\n * Internal dependencies\n */\nimport styles from './style.scss';\n\nexport {\n\tCircle,\n\tG,\n\tPath,\n\tPolygon,\n\tRect,\n\tDefs,\n\tRadialGradient,\n\tLinearGradient,\n\tStop,\n\tLine,\n} from 'react-native-svg';\n\nconst AnimatedSvg = Animated.createAnimatedComponent(\n\tforwardRef( ( props, ref ) => <Svg ref={ ref } { ...props } /> )\n);\n\nexport const SVG = ( {\n\tclassName = '',\n\tisPressed,\n\tanimated = false,\n\t...props\n} ) => {\n\tconst colorScheme = usePreferredColorScheme();\n\tconst stylesFromClasses = className\n\t\t.split( ' ' )\n\t\t.map( ( element ) => styles[ element ] )\n\t\t.filter( Boolean );\n\tconst defaultStyle = isPressed\n\t\t? styles[ `is-pressed--${ colorScheme }` ]\n\t\t: styles[ 'components-toolbar__control-' + colorScheme ];\n\tconst propStyle = Array.isArray( props.style )\n\t\t? props.style.reduce( ( acc, el ) => {\n\t\t\t\treturn { ...acc, ...el };\n\t\t }, {} )\n\t\t: props.style;\n\tconst styleValues = Object.assign(\n\t\t{},\n\t\tdefaultStyle,\n\t\tpropStyle,\n\t\t...stylesFromClasses\n\t);\n\n\tconst appliedProps = { ...props, style: styleValues };\n\n\tconst SvgWrapper = animated ? AnimatedSvg : Svg;\n\n\treturn (\n\t\t<SvgWrapper\n\t\t\t// We want to re-render when style color is changed.\n\t\t\tkey={ appliedProps.style.color }\n\t\t\theight=\"100%\"\n\t\t\twidth=\"100%\"\n\t\t\t{ ...appliedProps }\n\t\t/>\n\t);\n};\n"]}
@@ -10,6 +10,7 @@ import { Animated } from 'react-native';
10
10
  */
11
11
 
12
12
  import { forwardRef } from '@wordpress/element';
13
+ import { usePreferredColorScheme } from '@wordpress/compose';
13
14
  /**
14
15
  * Internal dependencies
15
16
  */
@@ -26,9 +27,9 @@ export const SVG = ({
26
27
  animated = false,
27
28
  ...props
28
29
  }) => {
29
- const colorScheme = props.colorScheme || 'light';
30
+ const colorScheme = usePreferredColorScheme();
30
31
  const stylesFromClasses = className.split(' ').map(element => styles[element]).filter(Boolean);
31
- const defaultStyle = isPressed ? styles['is-pressed'] : styles['components-toolbar__control-' + colorScheme];
32
+ const defaultStyle = isPressed ? styles[`is-pressed--${colorScheme}`] : styles['components-toolbar__control-' + colorScheme];
32
33
  const propStyle = Array.isArray(props.style) ? props.style.reduce((acc, el) => {
33
34
  return { ...acc,
34
35
  ...el
@@ -1 +1 @@
1
- {"version":3,"sources":["@wordpress/primitives/src/svg/index.native.js"],"names":["Svg","Animated","forwardRef","styles","Circle","G","Path","Polygon","Rect","Defs","RadialGradient","LinearGradient","Stop","Line","AnimatedSvg","createAnimatedComponent","props","ref","SVG","className","isPressed","animated","colorScheme","stylesFromClasses","split","map","element","filter","Boolean","defaultStyle","propStyle","Array","isArray","style","reduce","acc","el","styleValues","Object","assign","appliedProps","SvgWrapper","color"],"mappings":";;AAAA;AACA;AACA;AACA,SAASA,GAAT,QAAoB,kBAApB;AACA,SAASC,QAAT,QAAyB,cAAzB;AAEA;AACA;AACA;;AACA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BC,SAHmB,EAInB,GAAGP,iBAJgB,CAApB;AAOA,QAAMiB,YAAY,GAAG,EAAE,GAAGxB,KAAL;AAAYiB,IAAAA,KAAK,EAAEI;AAAnB,GAArB;AAEA,QAAMI,UAAU,GAAGpB,QAAQ,GAAGP,WAAH,GAAiBd,GAA5C;AAEA,SACC,cAAC,UAAD,CACC;AADD;AAEC,IAAA,GAAG,EAAGwC,YAAY,CAACP,KAAb,CAAmBS,KAF1B;AAGC,IAAA,MAAM,EAAC,MAHR;AAIC,IAAA,KAAK,EAAC,MAJP;AAAA,OAKMF;AALN,IADD;AASA,CAvCM","sourcesContent":["/**\n * External dependencies\n */\nimport { Svg } from 'react-native-svg';\nimport { Animated } from 'react-native';\n\n/**\n * WordPress dependencies\n */\nimport { forwardRef } from '@wordpress/element';\n\n/**\n * Internal dependencies\n */\nimport styles from './style.scss';\n\nexport {\n\tCircle,\n\tG,\n\tPath,\n\tPolygon,\n\tRect,\n\tDefs,\n\tRadialGradient,\n\tLinearGradient,\n\tStop,\n\tLine,\n} from 'react-native-svg';\n\nconst AnimatedSvg = Animated.createAnimatedComponent(\n\tforwardRef( ( props, ref ) => <Svg ref={ ref } { ...props } /> )\n);\n\nexport const SVG = ( {\n\tclassName = '',\n\tisPressed,\n\tanimated = false,\n\t...props\n} ) => {\n\tconst colorScheme = props.colorScheme || 'light';\n\tconst stylesFromClasses = className\n\t\t.split( ' ' )\n\t\t.map( ( element ) => styles[ element ] )\n\t\t.filter( Boolean );\n\tconst defaultStyle = isPressed\n\t\t? styles[ 'is-pressed' ]\n\t\t: styles[ 'components-toolbar__control-' + colorScheme ];\n\tconst propStyle = Array.isArray( props.style )\n\t\t? props.style.reduce( ( acc, el ) => {\n\t\t\t\treturn { ...acc, ...el };\n\t\t }, {} )\n\t\t: props.style;\n\tconst styleValues = Object.assign(\n\t\t{},\n\t\tdefaultStyle,\n\t\tpropStyle,\n\t\t...stylesFromClasses\n\t);\n\n\tconst appliedProps = { ...props, style: styleValues };\n\n\tconst SvgWrapper = animated ? AnimatedSvg : Svg;\n\n\treturn (\n\t\t<SvgWrapper\n\t\t\t// We want to re-render when style color is changed.\n\t\t\tkey={ appliedProps.style.color }\n\t\t\theight=\"100%\"\n\t\t\twidth=\"100%\"\n\t\t\t{ ...appliedProps }\n\t\t/>\n\t);\n};\n"]}
1
+ {"version":3,"sources":["@wordpress/primitives/src/svg/index.native.js"],"names":["Svg","Animated","forwardRef","usePreferredColorScheme","styles","Circle","G","Path","Polygon","Rect","Defs","RadialGradient","LinearGradient","Stop","Line","AnimatedSvg","createAnimatedComponent","props","ref","SVG","className","isPressed","animated","colorScheme","stylesFromClasses","split","map","element","filter","Boolean","defaultStyle","propStyle","Array","isArray","style","reduce","acc","el","styleValues","Object","assign","appliedProps","SvgWrapper","color"],"mappings":";;AAAA;AACA;AACA;AACA,SAASA,GAAT,QAAoB,kBAApB;AACA,SAASC,QAAT,QAAyB,cAAzB;AAEA;AACA;AACA;;AACA,SAASC,UAAT,QAA2B,oBAA3B;AACA,SAASC,uBAAT,QAAwC,oBAAxC;AAEA;AACA;AACA;;AACA,OAAOC,MAAP,MAAmB,cAAnB;AAEA,SACCC,MADD,EAECC,CAFD,EAGCC,IAHD,EAICC,OAJD,EAKCC,IALD,EAMCC,IAND,EAOCC,cAPD,EAQCC,cARD,EASCC,IATD,EAUCC,IAVD,QAWO,kBAXP;AAaA,MAAMC,WAAW,GAAGd,QAAQ,CAACe,uBAAT,CACnBd,UAAU,CAAE,CAAEe,KAAF,EAASC,GAAT,KAAkB,cAAC,GAAD;AAAK,EAAA,GAAG,EAAGA,GAAX;AAAA,KAAsBD;AAAtB,EAApB,CADS,CAApB;AAIA,OAAO,MAAME,GAAG,GAAG,CAAE;AACpBC,EAAAA,SAAS,GAAG,EADQ;AAEpBC,EAAAA,SAFoB;AAGpBC,EAAAA,QAAQ,GAAG,KAHS;AAIpB,KAAGL;AAJiB,CAAF,KAKZ;AACN,QAAMM,WAAW,GAAGpB,uBAAuB,EAA3C;AACA,QAAMqB,iBAAiB,GAAGJ,SAAS,CACjCK,KADwB,CACjB,GADiB,EAExBC,GAFwB,CAEjBC,OAAF,IAAevB,MAAM,CAAEuB,OAAF,CAFF,EAGxBC,MAHwB,CAGhBC,OAHgB,CAA1B;AAIA,QAAMC,YAAY,GAAGT,SAAS,GAC3BjB,MAAM,CAAG,eAAemB,WAAa,EAA/B,CADqB,GAE3BnB,MAAM,CAAE,iCAAiCmB,WAAnC,CAFT;AAGA,QAAMQ,SAAS,GAAGC,KAAK,CAACC,OAAN,CAAehB,KAAK,CAACiB,KAArB,IACfjB,KAAK,CAACiB,KAAN,CAAYC,MAAZ,CAAoB,CAAEC,GAAF,EAAOC,EAAP,KAAe;AACnC,WAAO,EAAE,GAAGD,GAAL;AAAU,SAAGC;AAAb,KAAP;AACC,GAFD,EAEG,EAFH,CADe,GAIfpB,KAAK,CAACiB,KAJT;AAKA,QAAMI,WAAW,GAAGC,MAAM,CAACC,MAAP,CACnB,EADmB,EAEnBV,YAFmB,EAGnBC,SAHmB,EAInB,GAAGP,iBAJgB,CAApB;AAOA,QAAMiB,YAAY,GAAG,EAAE,GAAGxB,KAAL;AAAYiB,IAAAA,KAAK,EAAEI;AAAnB,GAArB;AAEA,QAAMI,UAAU,GAAGpB,QAAQ,GAAGP,WAAH,GAAiBf,GAA5C;AAEA,SACC,cAAC,UAAD,CACC;AADD;AAEC,IAAA,GAAG,EAAGyC,YAAY,CAACP,KAAb,CAAmBS,KAF1B;AAGC,IAAA,MAAM,EAAC,MAHR;AAIC,IAAA,KAAK,EAAC,MAJP;AAAA,OAKMF;AALN,IADD;AASA,CAvCM","sourcesContent":["/**\n * External dependencies\n */\nimport { Svg } from 'react-native-svg';\nimport { Animated } from 'react-native';\n\n/**\n * WordPress dependencies\n */\nimport { forwardRef } from '@wordpress/element';\nimport { usePreferredColorScheme } from '@wordpress/compose';\n\n/**\n * Internal dependencies\n */\nimport styles from './style.scss';\n\nexport {\n\tCircle,\n\tG,\n\tPath,\n\tPolygon,\n\tRect,\n\tDefs,\n\tRadialGradient,\n\tLinearGradient,\n\tStop,\n\tLine,\n} from 'react-native-svg';\n\nconst AnimatedSvg = Animated.createAnimatedComponent(\n\tforwardRef( ( props, ref ) => <Svg ref={ ref } { ...props } /> )\n);\n\nexport const SVG = ( {\n\tclassName = '',\n\tisPressed,\n\tanimated = false,\n\t...props\n} ) => {\n\tconst colorScheme = usePreferredColorScheme();\n\tconst stylesFromClasses = className\n\t\t.split( ' ' )\n\t\t.map( ( element ) => styles[ element ] )\n\t\t.filter( Boolean );\n\tconst defaultStyle = isPressed\n\t\t? styles[ `is-pressed--${ colorScheme }` ]\n\t\t: styles[ 'components-toolbar__control-' + colorScheme ];\n\tconst propStyle = Array.isArray( props.style )\n\t\t? props.style.reduce( ( acc, el ) => {\n\t\t\t\treturn { ...acc, ...el };\n\t\t }, {} )\n\t\t: props.style;\n\tconst styleValues = Object.assign(\n\t\t{},\n\t\tdefaultStyle,\n\t\tpropStyle,\n\t\t...stylesFromClasses\n\t);\n\n\tconst appliedProps = { ...props, style: styleValues };\n\n\tconst SvgWrapper = animated ? AnimatedSvg : Svg;\n\n\treturn (\n\t\t<SvgWrapper\n\t\t\t// We want to re-render when style color is changed.\n\t\t\tkey={ appliedProps.style.color }\n\t\t\theight=\"100%\"\n\t\t\twidth=\"100%\"\n\t\t\t{ ...appliedProps }\n\t\t/>\n\t);\n};\n"]}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@wordpress/primitives",
3
- "version": "3.35.0",
3
+ "version": "3.36.0",
4
4
  "description": "WordPress cross-platform primitives.",
5
5
  "author": "The WordPress Contributors",
6
6
  "license": "GPL-2.0-or-later",
@@ -31,11 +31,11 @@
31
31
  "types": "build-types",
32
32
  "dependencies": {
33
33
  "@babel/runtime": "^7.16.0",
34
- "@wordpress/element": "^5.14.0",
34
+ "@wordpress/element": "^5.15.0",
35
35
  "classnames": "^2.3.1"
36
36
  },
37
37
  "publishConfig": {
38
38
  "access": "public"
39
39
  },
40
- "gitHead": "bcd13d59b22553b3c9dc5869077bff1e864cf9f5"
40
+ "gitHead": "6f14d11ed4cb59df110a28ebaa23ecba95eb673a"
41
41
  }
@@ -8,6 +8,7 @@ import { Animated } from 'react-native';
8
8
  * WordPress dependencies
9
9
  */
10
10
  import { forwardRef } from '@wordpress/element';
11
+ import { usePreferredColorScheme } from '@wordpress/compose';
11
12
 
12
13
  /**
13
14
  * Internal dependencies
@@ -37,13 +38,13 @@ export const SVG = ( {
37
38
  animated = false,
38
39
  ...props
39
40
  } ) => {
40
- const colorScheme = props.colorScheme || 'light';
41
+ const colorScheme = usePreferredColorScheme();
41
42
  const stylesFromClasses = className
42
43
  .split( ' ' )
43
44
  .map( ( element ) => styles[ element ] )
44
45
  .filter( Boolean );
45
46
  const defaultStyle = isPressed
46
- ? styles[ 'is-pressed' ]
47
+ ? styles[ `is-pressed--${ colorScheme }` ]
47
48
  : styles[ 'components-toolbar__control-' + colorScheme ];
48
49
  const propStyle = Array.isArray( props.style )
49
50
  ? props.style.reduce( ( acc, el ) => {
@@ -1,21 +1,30 @@
1
1
  .dashicon-light,
2
2
  .components-toolbar__control-light {
3
- color: $toolbar-button;
3
+ color: $light-primary;
4
4
  fill: currentColor;
5
5
  }
6
6
 
7
7
  .dashicon-dark,
8
8
  .components-toolbar__control-dark {
9
- color: $gray_20;
9
+ color: $dark-primary;
10
10
  fill: currentColor;
11
11
  }
12
12
 
13
- .dashicon-active,
14
- .is-pressed {
13
+ .dashicon-active {
15
14
  color: #fff;
16
15
  fill: currentColor;
17
16
  }
18
17
 
18
+ .is-pressed--light {
19
+ color: $light-primary;
20
+ fill: currentColor;
21
+ }
22
+
23
+ .is-pressed--dark {
24
+ color: $dark-primary;
25
+ fill: currentColor;
26
+ }
27
+
19
28
  .dashicons-insert {
20
29
  color: #87a6bc;
21
30
  fill: currentColor;