@drivy/cobalt 0.29.1 → 0.30.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.
Files changed (33) hide show
  1. package/cjs/tokens/theme.js +1 -1
  2. package/components/Card/index.js +3 -2
  3. package/components/Card/index.js.map +1 -1
  4. package/components/Flash/index.js +4 -4
  5. package/components/Flash/index.js.map +1 -1
  6. package/components/Form/Autocomplete/index.js +1 -1
  7. package/components/Form/Autocomplete/index.js.map +1 -1
  8. package/package.json +1 -1
  9. package/styles/components/Alerter/index.scss +2 -4
  10. package/styles/components/BulletList/index.scss +1 -2
  11. package/styles/components/Buttons/index.scss +0 -1
  12. package/styles/components/Calendar/CalendarRangePicker/index.scss +13 -18
  13. package/styles/components/Calendar/CalendarView/index.scss +6 -8
  14. package/styles/components/Card/index.scss +16 -6
  15. package/styles/components/Flash/index.scss +2 -4
  16. package/styles/components/Form/Autocomplete/index.scss +10 -21
  17. package/styles/components/Form/CheckablePill.scss +1 -2
  18. package/styles/components/Form/Checkmark.scss +1 -5
  19. package/styles/components/Form/Hint.scss +0 -9
  20. package/styles/components/Form/RadioWithDetails.scss +2 -2
  21. package/styles/components/Helper/index.scss +0 -3
  22. package/styles/components/Icon/index.scss +1 -2
  23. package/styles/components/Note/index.scss +4 -0
  24. package/styles/components/PhotoDropzone/index.scss +1 -2
  25. package/styles/components/TabBar/index.scss +1 -1
  26. package/styles/components/Tag/index.scss +2 -4
  27. package/styles/core/_colors-map.scss +164 -164
  28. package/styles/core/text.scss +38 -20
  29. package/styles/core/theme.scss +160 -160
  30. package/styles/core/typography.scss +12 -12
  31. package/tokens/theme.js +1 -1
  32. package/types/components/Card/index.d.ts +3 -1
  33. package/utilities.css +418 -388
@@ -48,7 +48,7 @@ const text = {
48
48
  base: "graphite/navy.700/grey.100",
49
49
  baseInteractive: {
50
50
  DEFAULT: "graphite/navy.700/grey.100",
51
- hover: "graphite/navy.900/grey.100"
51
+ hover: "graphite/navy.300/grey.300"
52
52
  },
53
53
  subdued: "graphite.light/navy.300/grey.300",
54
54
  subduedInteractive: {
@@ -1,8 +1,9 @@
1
1
  import React, { PureComponent } from 'react';
2
2
  import cx from 'classnames';
3
3
 
4
- const Card = ({ children, className, flattened }) => (React.createElement("div", { className: cx("cobalt-Card", className, {
5
- "cobalt-Card--flattened": flattened,
4
+ const Card = ({ children, className, legacy, responsive, }) => (React.createElement("div", { className: cx("cobalt-Card", className, {
5
+ "cobalt-Card--legacy": legacy,
6
+ "cobalt-Card--responsive": responsive,
6
7
  }) }, children));
7
8
  const getClasses = ({ className = "", tabBar, tight, subdued, divided, }) => {
8
9
  return cx(className, "cobalt-Card__Section", {
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sources":["../../../src/components/Card/index.tsx"],"sourcesContent":["import React, { PureComponent } from \"react\"\nimport cx from \"classnames\"\n\nexport type CardProps = {\n children?: React.ReactNode\n className?: string\n flattened?: boolean\n}\n\nexport const Card = ({ children, className, flattened }: CardProps) => (\n <div\n className={cx(\"cobalt-Card\", className, {\n \"cobalt-Card--flattened\": flattened,\n })}\n >\n {children}\n </div>\n)\n\nexport type CardSectionProps = {\n children: React.ReactNode\n className?: string\n tabBar?: boolean\n tight?: boolean\n subdued?: boolean\n /**\n * true or \"soft\"\n * @default false\n */\n divided?: boolean | string\n}\n\nexport type CardSectionLinkProps = CardSectionProps & {\n href: React.AnchorHTMLAttributes<HTMLAnchorElement>[\"href\"]\n target?: React.AnchorHTMLAttributes<HTMLAnchorElement>[\"target\"]\n rel?: React.AnchorHTMLAttributes<HTMLAnchorElement>[\"rel\"]\n}\n\nconst getClasses = ({\n className = \"\",\n tabBar,\n tight,\n subdued,\n divided,\n}: CardSectionProps) => {\n return cx(className, \"cobalt-Card__Section\", {\n \"cobalt-Card__Section--tabBar\": tabBar === true,\n \"cobalt-Card__Section--tight\": tight === true,\n \"cobalt-Card__Section--subdued\": subdued === true,\n \"cobalt-Card__Section--divided\": divided === true,\n \"cobalt-Card__Section--dividedSoft\": divided === \"soft\",\n })\n}\n\nconst CardSectionLink = ({\n href,\n target,\n rel,\n ...baseProps\n}: CardSectionLinkProps) => {\n return (\n <a\n className={getClasses(baseProps)}\n href={href}\n target={target}\n rel={target && !rel ? \"noopener noreferrer\" : rel}\n >\n {baseProps.children}\n </a>\n )\n}\nCardSectionLink.displayName = \"CardSection.Link\"\n\nexport class CardSection extends PureComponent<CardSectionProps, never> {\n static Link = CardSectionLink\n render() {\n return <div className={getClasses(this.props)}>{this.props.children}</div>\n }\n}\n\nCard.Section = CardSection\n\nexport default Card\n"],"names":[],"mappings":";;;AASa,MAAA,IAAI,GAAG,CAAC,EAAE,QAAQ,EAAE,SAAS,EAAE,SAAS,EAAa,MAChE,KAAA,CAAA,aAAA,CAAA,KAAA,EAAA,EACE,SAAS,EAAE,EAAE,CAAC,aAAa,EAAE,SAAS,EAAE;AACtC,QAAA,wBAAwB,EAAE,SAAS;AACpC,KAAA,CAAC,EAED,EAAA,QAAQ,CACL,EACP;AAqBD,MAAM,UAAU,GAAG,CAAC,EAClB,SAAS,GAAG,EAAE,EACd,MAAM,EACN,KAAK,EACL,OAAO,EACP,OAAO,GACU,KAAI;AACrB,IAAA,OAAO,EAAE,CAAC,SAAS,EAAE,sBAAsB,EAAE;QAC3C,8BAA8B,EAAE,MAAM,KAAK,IAAI;QAC/C,6BAA6B,EAAE,KAAK,KAAK,IAAI;QAC7C,+BAA+B,EAAE,OAAO,KAAK,IAAI;QACjD,+BAA+B,EAAE,OAAO,KAAK,IAAI;QACjD,mCAAmC,EAAE,OAAO,KAAK,MAAM;AACxD,KAAA,CAAC,CAAA;AACJ,CAAC,CAAA;AAED,MAAM,eAAe,GAAG,CAAC,EACvB,IAAI,EACJ,MAAM,EACN,GAAG,EACH,GAAG,SAAS,EACS,KAAI;AACzB,IAAA,QACE,KACE,CAAA,aAAA,CAAA,GAAA,EAAA,EAAA,SAAS,EAAE,UAAU,CAAC,SAAS,CAAC,EAChC,IAAI,EAAE,IAAI,EACV,MAAM,EAAE,MAAM,EACd,GAAG,EAAE,MAAM,IAAI,CAAC,GAAG,GAAG,qBAAqB,GAAG,GAAG,EAEhD,EAAA,SAAS,CAAC,QAAQ,CACjB,EACL;AACH,CAAC,CAAA;AACD,eAAe,CAAC,WAAW,GAAG,kBAAkB,CAAA;AAE1C,MAAO,WAAY,SAAQ,aAAsC,CAAA;IAErE,MAAM,GAAA;AACJ,QAAA,OAAO,6BAAK,SAAS,EAAE,UAAU,CAAC,IAAI,CAAC,KAAK,CAAC,EAAA,EAAG,IAAI,CAAC,KAAK,CAAC,QAAQ,CAAO,CAAA;KAC3E;;AAHM,WAAI,CAAA,IAAA,GAAG,eAAe,CAAA;AAM/B,IAAI,CAAC,OAAO,GAAG,WAAW;;;;"}
1
+ {"version":3,"file":"index.js","sources":["../../../src/components/Card/index.tsx"],"sourcesContent":["import React, { PureComponent } from \"react\"\nimport cx from \"classnames\"\n\nexport type CardProps = {\n children?: React.ReactNode\n className?: string\n legacy?: boolean\n // Not used anymore, to remove in the next release\n flattened?: boolean\n responsive?: boolean\n}\n\nexport const Card = ({\n children,\n className,\n legacy,\n responsive,\n}: CardProps) => (\n <div\n className={cx(\"cobalt-Card\", className, {\n \"cobalt-Card--legacy\": legacy,\n \"cobalt-Card--responsive\": responsive,\n })}\n >\n {children}\n </div>\n)\n\nexport type CardSectionProps = {\n children: React.ReactNode\n className?: string\n tabBar?: boolean\n tight?: boolean\n subdued?: boolean\n /**\n * true or \"soft\"\n * @default false\n */\n divided?: boolean | string\n}\n\nexport type CardSectionLinkProps = CardSectionProps & {\n href: React.AnchorHTMLAttributes<HTMLAnchorElement>[\"href\"]\n target?: React.AnchorHTMLAttributes<HTMLAnchorElement>[\"target\"]\n rel?: React.AnchorHTMLAttributes<HTMLAnchorElement>[\"rel\"]\n}\n\nconst getClasses = ({\n className = \"\",\n tabBar,\n tight,\n subdued,\n divided,\n}: CardSectionProps) => {\n return cx(className, \"cobalt-Card__Section\", {\n \"cobalt-Card__Section--tabBar\": tabBar === true,\n \"cobalt-Card__Section--tight\": tight === true,\n \"cobalt-Card__Section--subdued\": subdued === true,\n \"cobalt-Card__Section--divided\": divided === true,\n \"cobalt-Card__Section--dividedSoft\": divided === \"soft\",\n })\n}\n\nconst CardSectionLink = ({\n href,\n target,\n rel,\n ...baseProps\n}: CardSectionLinkProps) => {\n return (\n <a\n className={getClasses(baseProps)}\n href={href}\n target={target}\n rel={target && !rel ? \"noopener noreferrer\" : rel}\n >\n {baseProps.children}\n </a>\n )\n}\nCardSectionLink.displayName = \"CardSection.Link\"\n\nexport class CardSection extends PureComponent<CardSectionProps, never> {\n static Link = CardSectionLink\n render() {\n return <div className={getClasses(this.props)}>{this.props.children}</div>\n }\n}\n\nCard.Section = CardSection\n\nexport default Card\n"],"names":[],"mappings":";;;AAYa,MAAA,IAAI,GAAG,CAAC,EACnB,QAAQ,EACR,SAAS,EACT,MAAM,EACN,UAAU,GACA,MACV,KACE,CAAA,aAAA,CAAA,KAAA,EAAA,EAAA,SAAS,EAAE,EAAE,CAAC,aAAa,EAAE,SAAS,EAAE;AACtC,QAAA,qBAAqB,EAAE,MAAM;AAC7B,QAAA,yBAAyB,EAAE,UAAU;AACtC,KAAA,CAAC,EAED,EAAA,QAAQ,CACL,EACP;AAqBD,MAAM,UAAU,GAAG,CAAC,EAClB,SAAS,GAAG,EAAE,EACd,MAAM,EACN,KAAK,EACL,OAAO,EACP,OAAO,GACU,KAAI;AACrB,IAAA,OAAO,EAAE,CAAC,SAAS,EAAE,sBAAsB,EAAE;QAC3C,8BAA8B,EAAE,MAAM,KAAK,IAAI;QAC/C,6BAA6B,EAAE,KAAK,KAAK,IAAI;QAC7C,+BAA+B,EAAE,OAAO,KAAK,IAAI;QACjD,+BAA+B,EAAE,OAAO,KAAK,IAAI;QACjD,mCAAmC,EAAE,OAAO,KAAK,MAAM;AACxD,KAAA,CAAC,CAAA;AACJ,CAAC,CAAA;AAED,MAAM,eAAe,GAAG,CAAC,EACvB,IAAI,EACJ,MAAM,EACN,GAAG,EACH,GAAG,SAAS,EACS,KAAI;AACzB,IAAA,QACE,KACE,CAAA,aAAA,CAAA,GAAA,EAAA,EAAA,SAAS,EAAE,UAAU,CAAC,SAAS,CAAC,EAChC,IAAI,EAAE,IAAI,EACV,MAAM,EAAE,MAAM,EACd,GAAG,EAAE,MAAM,IAAI,CAAC,GAAG,GAAG,qBAAqB,GAAG,GAAG,EAEhD,EAAA,SAAS,CAAC,QAAQ,CACjB,EACL;AACH,CAAC,CAAA;AACD,eAAe,CAAC,WAAW,GAAG,kBAAkB,CAAA;AAE1C,MAAO,WAAY,SAAQ,aAAsC,CAAA;IAErE,MAAM,GAAA;AACJ,QAAA,OAAO,6BAAK,SAAS,EAAE,UAAU,CAAC,IAAI,CAAC,KAAK,CAAC,EAAA,EAAG,IAAI,CAAC,KAAK,CAAC,QAAQ,CAAO,CAAA;KAC3E;;AAHM,WAAI,CAAA,IAAA,GAAG,eAAe,CAAA;AAM/B,IAAI,CAAC,OAAO,GAAG,WAAW;;;;"}
@@ -8,9 +8,9 @@ const STATUS_ICONS_MAP = {
8
8
  error: "contextualWarningCircleFilled",
9
9
  };
10
10
  const STATUS_ICON_COLOR_MAP = {
11
- info: "turquoise",
12
- success: "green",
13
- error: "red",
11
+ info: "info",
12
+ success: "success",
13
+ error: "error",
14
14
  };
15
15
  const Flash = ({ children, status = "info" }) => {
16
16
  const icon = STATUS_ICONS_MAP[status]
@@ -18,7 +18,7 @@ const Flash = ({ children, status = "info" }) => {
18
18
  : "infoFilled";
19
19
  const iconColor = STATUS_ICON_COLOR_MAP[status]
20
20
  ? STATUS_ICON_COLOR_MAP[status]
21
- : "turquoise";
21
+ : "base";
22
22
  return (React.createElement("div", { className: `cobalt-Flash cobalt-Flash--${status}` },
23
23
  React.createElement("div", { className: "cobalt-Flash__wrapper" },
24
24
  React.createElement("span", { className: "cobalt-Flash__Icon" },
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sources":["../../../src/components/Flash/index.tsx"],"sourcesContent":["import React from \"react\"\nimport { Icon, IconColorsType, IconSources } from \"../Icon\"\n\nexport type FlashStatus = \"info\" | \"success\" | \"error\"\n\nexport interface FlashProps {\n children: React.ReactNode\n status: FlashStatus\n}\n\nconst ICON_SIZE = 20\n\nconst STATUS_ICONS_MAP: { [k in FlashStatus]: IconSources } = {\n info: \"infoFilled\",\n success: \"checkCircle\",\n error: \"contextualWarningCircleFilled\",\n}\n\nconst STATUS_ICON_COLOR_MAP: { [k in FlashStatus]: IconColorsType } = {\n info: \"turquoise\",\n success: \"green\",\n error: \"red\",\n}\n\nexport const Flash = ({ children, status = \"info\" }: FlashProps) => {\n const icon = STATUS_ICONS_MAP[status]\n ? STATUS_ICONS_MAP[status]\n : \"infoFilled\"\n\n const iconColor: IconColorsType = STATUS_ICON_COLOR_MAP[status]\n ? STATUS_ICON_COLOR_MAP[status]\n : \"turquoise\"\n\n return (\n <div className={`cobalt-Flash cobalt-Flash--${status}`}>\n <div className=\"cobalt-Flash__wrapper\">\n <span className=\"cobalt-Flash__Icon\">\n <Icon source={icon} size={ICON_SIZE} color={iconColor} />\n </span>\n <span className=\"cobalt-Flash__content\">{children}</span>\n </div>\n </div>\n )\n}\n"],"names":[],"mappings":";;;AAUA,MAAM,SAAS,GAAG,EAAE,CAAA;AAEpB,MAAM,gBAAgB,GAAwC;AAC5D,IAAA,IAAI,EAAE,YAAY;AAClB,IAAA,OAAO,EAAE,aAAa;AACtB,IAAA,KAAK,EAAE,+BAA+B;CACvC,CAAA;AAED,MAAM,qBAAqB,GAA2C;AACpE,IAAA,IAAI,EAAE,WAAW;AACjB,IAAA,OAAO,EAAE,OAAO;AAChB,IAAA,KAAK,EAAE,KAAK;CACb,CAAA;AAEM,MAAM,KAAK,GAAG,CAAC,EAAE,QAAQ,EAAE,MAAM,GAAG,MAAM,EAAc,KAAI;AACjE,IAAA,MAAM,IAAI,GAAG,gBAAgB,CAAC,MAAM,CAAC;AACnC,UAAE,gBAAgB,CAAC,MAAM,CAAC;UACxB,YAAY,CAAA;AAEhB,IAAA,MAAM,SAAS,GAAmB,qBAAqB,CAAC,MAAM,CAAC;AAC7D,UAAE,qBAAqB,CAAC,MAAM,CAAC;UAC7B,WAAW,CAAA;AAEf,IAAA,QACE,KAAK,CAAA,aAAA,CAAA,KAAA,EAAA,EAAA,SAAS,EAAE,CAAA,2BAAA,EAA8B,MAAM,CAAE,CAAA,EAAA;QACpD,KAAK,CAAA,aAAA,CAAA,KAAA,EAAA,EAAA,SAAS,EAAC,uBAAuB,EAAA;YACpC,KAAM,CAAA,aAAA,CAAA,MAAA,EAAA,EAAA,SAAS,EAAC,oBAAoB,EAAA;AAClC,gBAAA,KAAA,CAAA,aAAA,CAAC,IAAI,EAAA,EAAC,MAAM,EAAE,IAAI,EAAE,IAAI,EAAE,SAAS,EAAE,KAAK,EAAE,SAAS,GAAI,CACpD;YACP,KAAM,CAAA,aAAA,CAAA,MAAA,EAAA,EAAA,SAAS,EAAC,uBAAuB,EAAA,EAAE,QAAQ,CAAQ,CACrD,CACF,EACP;AACH;;;;"}
1
+ {"version":3,"file":"index.js","sources":["../../../src/components/Flash/index.tsx"],"sourcesContent":["import React from \"react\"\nimport { Icon, IconColorsType, IconSources } from \"../Icon\"\n\nexport type FlashStatus = \"info\" | \"success\" | \"error\"\n\nexport interface FlashProps {\n children: React.ReactNode\n status: FlashStatus\n}\n\nconst ICON_SIZE = 20\n\nconst STATUS_ICONS_MAP: { [k in FlashStatus]: IconSources } = {\n info: \"infoFilled\",\n success: \"checkCircle\",\n error: \"contextualWarningCircleFilled\",\n}\n\nconst STATUS_ICON_COLOR_MAP: { [k in FlashStatus]: IconColorsType } = {\n info: \"info\",\n success: \"success\",\n error: \"error\",\n}\n\nexport const Flash = ({ children, status = \"info\" }: FlashProps) => {\n const icon = STATUS_ICONS_MAP[status]\n ? STATUS_ICONS_MAP[status]\n : \"infoFilled\"\n\n const iconColor: IconColorsType = STATUS_ICON_COLOR_MAP[status]\n ? STATUS_ICON_COLOR_MAP[status]\n : \"base\"\n\n return (\n <div className={`cobalt-Flash cobalt-Flash--${status}`}>\n <div className=\"cobalt-Flash__wrapper\">\n <span className=\"cobalt-Flash__Icon\">\n <Icon source={icon} size={ICON_SIZE} color={iconColor} />\n </span>\n <span className=\"cobalt-Flash__content\">{children}</span>\n </div>\n </div>\n )\n}\n"],"names":[],"mappings":";;;AAUA,MAAM,SAAS,GAAG,EAAE,CAAA;AAEpB,MAAM,gBAAgB,GAAwC;AAC5D,IAAA,IAAI,EAAE,YAAY;AAClB,IAAA,OAAO,EAAE,aAAa;AACtB,IAAA,KAAK,EAAE,+BAA+B;CACvC,CAAA;AAED,MAAM,qBAAqB,GAA2C;AACpE,IAAA,IAAI,EAAE,MAAM;AACZ,IAAA,OAAO,EAAE,SAAS;AAClB,IAAA,KAAK,EAAE,OAAO;CACf,CAAA;AAEM,MAAM,KAAK,GAAG,CAAC,EAAE,QAAQ,EAAE,MAAM,GAAG,MAAM,EAAc,KAAI;AACjE,IAAA,MAAM,IAAI,GAAG,gBAAgB,CAAC,MAAM,CAAC;AACnC,UAAE,gBAAgB,CAAC,MAAM,CAAC;UACxB,YAAY,CAAA;AAEhB,IAAA,MAAM,SAAS,GAAmB,qBAAqB,CAAC,MAAM,CAAC;AAC7D,UAAE,qBAAqB,CAAC,MAAM,CAAC;UAC7B,MAAM,CAAA;AAEV,IAAA,QACE,KAAK,CAAA,aAAA,CAAA,KAAA,EAAA,EAAA,SAAS,EAAE,CAAA,2BAAA,EAA8B,MAAM,CAAE,CAAA,EAAA;QACpD,KAAK,CAAA,aAAA,CAAA,KAAA,EAAA,EAAA,SAAS,EAAC,uBAAuB,EAAA;YACpC,KAAM,CAAA,aAAA,CAAA,MAAA,EAAA,EAAA,SAAS,EAAC,oBAAoB,EAAA;AAClC,gBAAA,KAAA,CAAA,aAAA,CAAC,IAAI,EAAA,EAAC,MAAM,EAAE,IAAI,EAAE,IAAI,EAAE,SAAS,EAAE,KAAK,EAAE,SAAS,GAAI,CACpD;YACP,KAAM,CAAA,aAAA,CAAA,MAAA,EAAA,EAAA,SAAS,EAAC,uBAAuB,EAAA,EAAE,QAAQ,CAAQ,CACrD,CACF,EACP;AACH;;;;"}
@@ -151,7 +151,7 @@ function Autocomplete({ id, icon, status, items, selectedItem, autoFilter = true
151
151
  handleSelectItem(item, e);
152
152
  } }, renderItem ? (renderItem(item, term)) : (React.createElement("span", { className: "cobalt-Autocomplete__item-wrapper" },
153
153
  icon && (React.createElement("span", { className: "cobalt-Autocomplete__item-icon" },
154
- React.createElement(Icon, { source: icon, color: "indigo" }))),
154
+ React.createElement(Icon, { source: icon, color: "accent" }))),
155
155
  React.createElement("span", { className: "cobalt-Autocomplete__item-value" },
156
156
  React.createElement(ComboboxOptionText, null)))))))))),
157
157
  React.createElement("div", { className: "cobalt-Autocomplete__input-wrapper" },
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sources":["../../../../src/components/Form/Autocomplete/index.tsx"],"sourcesContent":["import React, { useEffect, useRef, ElementType } from \"react\"\nimport { useState } from \"react\"\nimport classNames from \"classnames\"\n\nimport {\n Combobox,\n ComboboxInput,\n ComboboxPopover,\n ComboboxList,\n ComboboxOption,\n ComboboxOptionText,\n} from \"@reach/combobox\"\n\nimport { Icon, IconSources } from \"../../Icon\"\n\nimport { withFieldLabelAndHint } from \"../field\"\nimport { TextInputWrapper } from \"../TextInput\"\nimport { FormElement } from \"../form\"\n\nexport interface AutocompleteItem {\n [x: string]: any\n}\n\ntype ComboboxPopoverType = ElementType<\"div\"> & HTMLDivElement\ntype ComboboxOptionType = HTMLLIElement & React.ElementType<\"li\">\ntype ComboboxOptionMouseEventType = React.MouseEvent<\n ComboboxOptionType,\n MouseEvent\n>\n\ntype Props = {\n icon?: IconSources\n items: (AutocompleteItem | string)[]\n minQueryLength?: number\n autoFilter?: boolean\n selectedItem?: AutocompleteItem\n focusOnInit?: boolean\n autocomplete?: boolean\n valueKey?: string\n inputRef?: React.RefObject<HTMLInputElement>\n autocompleteRef?: React.RefObject<HTMLDivElement>\n onKeyDown?: (event: React.KeyboardEvent<HTMLElement>) => void\n onBlur?: (event: React.FocusEvent<HTMLInputElement>) => void\n onFocus?: (event: React.FocusEvent<HTMLInputElement>) => void\n onQueryChange?: (term: string) => void\n onSelectItem?: (item: AutocompleteItem, term: string) => boolean\n renderItem?: (item: AutocompleteItem, term: string) => React.ReactNode\n} & FormElement &\n React.InputHTMLAttributes<HTMLInputElement>\n\nfunction filterMatchingItems(\n items: AutocompleteItem[],\n term: string,\n minLength: number,\n valueKey: string\n) {\n const [matchingItems, setMatchingItems] = useState<AutocompleteItem[]>([])\n\n useEffect(() => {\n term.length >= minLength\n ? setMatchingItems(\n items.filter((item: AutocompleteItem) => {\n return item[valueKey].toLowerCase().indexOf(term.toLowerCase()) > -1\n })\n )\n : setMatchingItems([])\n }, [items, term, valueKey])\n\n return matchingItems\n}\n\nfunction sanitizeItems(items: (AutocompleteItem | string)[], valueKey: string) {\n const [sanitizedItems, setSanitizedItems] = useState<AutocompleteItem[]>([])\n useEffect(() => {\n setSanitizedItems(\n items.map((item) =>\n typeof item === \"string\" ? { [valueKey]: item } : item\n )\n )\n }, [items])\n return sanitizedItems\n}\n\nfunction Autocomplete({\n id,\n icon,\n status,\n items,\n selectedItem,\n autoFilter = true,\n minQueryLength = 1,\n focusOnInit = false,\n onKeyDown,\n onFocus,\n onBlur,\n onQueryChange,\n onSelectItem,\n renderItem,\n inputRef,\n autocompleteRef,\n valueKey = \"value\",\n ...inputProps\n}: Props) {\n const [term, setTerm] = useState(\"\")\n\n const [hasFocus, setHasFocus] = useState(false)\n\n let ignoreFocus = false // extra flag to ignore programmatical focus triggered by click on item\n\n const results = autoFilter\n ? filterMatchingItems(\n sanitizeItems(items, valueKey),\n term,\n minQueryLength,\n valueKey\n )\n : sanitizeItems(items, valueKey)\n\n const comboboxEl = autocompleteRef || useRef<HTMLDivElement>(null)\n\n const inputEl = inputRef || useRef<HTMLInputElement>(null)\n\n const popoverEl = useRef<ComboboxPopoverType>(null)\n\n const giveInputFocus = () => {\n inputEl.current && inputEl.current.focus()\n }\n\n const isMounted = useRef(true)\n const forceIdTimer = useRef<any>()\n const focusTimer = useRef<any>()\n const blurTimer = useRef<any>()\n const clearInputTimer = useRef<any>()\n\n function forceId() {\n // id is overriden by Reach ui Combobox\n forceIdTimer.current = setTimeout(() => {\n id && inputEl.current && inputEl.current.setAttribute(\"id\", id)\n })\n }\n\n useEffect(() => {\n // on mount ...\n focusOnInit && giveInputFocus()\n\n return () => {\n isMounted.current = false\n forceIdTimer.current && clearTimeout(forceIdTimer.current)\n focusTimer.current && clearTimeout(focusTimer.current)\n blurTimer.current && clearTimeout(blurTimer.current)\n clearInputTimer.current && clearTimeout(clearInputTimer.current)\n }\n }, [])\n\n useEffect(() => {\n forceId()\n }, [id])\n\n useEffect(() => {\n setTerm(selectedItem ? \"\" + selectedItem[valueKey] : \"\")\n }, [selectedItem])\n\n const handleFocus = (event: React.FocusEvent<HTMLInputElement>) => {\n !ignoreFocus && onFocus && onFocus(event)\n ignoreFocus = false\n focusTimer.current = setTimeout(() => {\n // required by \"forceDisplayResults\" mechanism\n isMounted.current && setHasFocus(true)\n }, 100)\n }\n\n const handleBlur = (event: React.FocusEvent<HTMLInputElement>) => {\n // blur interceptor required by \"forceDisplayResults\" mechanism\n onBlur && onBlur(event)\n blurTimer.current = setTimeout(() => {\n isMounted.current && setHasFocus(false)\n }, 100)\n }\n\n const handleChange = (event: React.FocusEvent<HTMLInputElement>) => {\n const inputValue = (event.target as HTMLInputElement).value\n if (inputValue.trim().length || term.length) {\n // to prevent starting with a space character\n setTerm(inputValue)\n onQueryChange && onQueryChange(inputValue)\n }\n }\n\n const handleClearInput = () => {\n setTerm(\"\")\n onQueryChange && onQueryChange(\"\")\n\n clearInputTimer.current = setTimeout(giveInputFocus) //timeout to trigger openOnFocus\n }\n\n const handleSelectItem = (\n item: AutocompleteItem,\n e: ComboboxOptionMouseEventType | React.KeyboardEvent<HTMLElement>\n ) => {\n // item click interceptor to enable custom select cancellation\n const processSelection = onSelectItem\n ? onSelectItem(item, term) !== false\n : true\n\n if (processSelection) {\n setTerm(item[valueKey])\n } else if (e) {\n e.preventDefault()\n ignoreFocus = true\n giveInputFocus()\n }\n }\n\n const handleKeyDown = (e: React.KeyboardEvent<HTMLElement>) => {\n onKeyDown && onKeyDown(e)\n\n // ENTER key down interceptor to enable custom select cancellation\n const KEY_CODE_ENTER = 13\n\n // BACKSPACE key down interceptor to synchonize react input value and dom input value in some edge case (Comnbobox autocomplete = true)\n const KEY_CODE_BACKSPACE = 8\n\n if (e.keyCode === KEY_CODE_ENTER) {\n if (!popoverEl.current) return\n\n const options = Array.from(\n popoverEl.current.querySelectorAll(\"[data-reach-combobox-option]\")\n )\n\n const selectedItemIndex = options.findIndex(\n (el) => el.getAttribute(\"aria-selected\") === \"true\"\n )\n\n selectedItemIndex >= 0 && handleSelectItem(results[selectedItemIndex], e)\n } else if (e.keyCode === KEY_CODE_BACKSPACE) {\n if (!inputEl.current) return\n if (inputEl.current.value.slice(0, -1) === term) {\n setTerm(inputEl.current.value)\n }\n }\n }\n\n const shouldDisplayItemsOnEmptyQuery = () => {\n return !autoFilter && results.length > 0 && term.length === 0 && hasFocus\n }\n\n const handleMouseDown = (\n item: AutocompleteItem,\n e: ComboboxOptionMouseEventType\n ) => {\n // In a specific case, we force the popover to display (results available, empty input using backspace)\n // But doing so, reach ui component is not ready for this case and will raise an error\n // We need to prevent the error and to force the selection\n if (\n shouldDisplayItemsOnEmptyQuery() &&\n popoverEl.current &&\n popoverEl.current.getAttribute(\"hidden\") != null\n ) {\n e.preventDefault() // it will prevent reach ui combobox to raise an error\n handleSelectItem(item, e) // we force the selection to be processed\n }\n }\n\n return (\n <Combobox\n className={classNames(\"cobalt-Autocomplete\", {\n \"cobalt-Autocomplete--forceDisplayResults\":\n shouldDisplayItemsOnEmptyQuery(), // Combobox Component, by design, hide the popover when the input is empty (on change) even if there are some results.\n })}\n as=\"div\"\n openOnFocus={true}\n ref={comboboxEl}\n >\n {results.length > 0 && (\n <ComboboxPopover\n className=\"cobalt-Autocomplete__popover\"\n portal={false}\n ref={popoverEl}\n >\n <ComboboxList\n className=\"cobalt-Autocomplete__list\"\n aria-label=\"Autocomplete option\"\n >\n {results.map((item, index) => (\n <ComboboxOption\n className=\"cobalt-Autocomplete__item\"\n key={index}\n value={item[valueKey]}\n onMouseDown={(e: ComboboxOptionMouseEventType) => {\n handleMouseDown(item, e)\n }}\n onClick={(e: ComboboxOptionMouseEventType) => {\n handleSelectItem(item, e)\n }}\n >\n {renderItem ? (\n renderItem(item, term)\n ) : (\n <span className=\"cobalt-Autocomplete__item-wrapper\">\n {icon && (\n <span className=\"cobalt-Autocomplete__item-icon\">\n <Icon source={icon} color=\"indigo\" />\n </span>\n )}\n\n <span className=\"cobalt-Autocomplete__item-value\">\n <ComboboxOptionText />\n </span>\n </span>\n )}\n </ComboboxOption>\n ))}\n </ComboboxList>\n </ComboboxPopover>\n )}\n <div className=\"cobalt-Autocomplete__input-wrapper\">\n <TextInputWrapper\n icon={icon}\n status={status}\n render={(className) => {\n return (\n <ComboboxInput\n {...inputProps}\n autoComplete=\"off\"\n autoCorrect=\"off\"\n autoCapitalize=\"off\"\n spellCheck={false}\n aria-label=\"autocomplete input\"\n type=\"text\"\n value={term}\n onChange={handleChange}\n onBlur={handleBlur}\n onFocus={handleFocus}\n onKeyDown={handleKeyDown}\n ref={inputEl}\n className={className}\n />\n )\n }}\n />\n\n {term && (\n <div\n className=\"cobalt-Autocomplete__clear-button\"\n role=\"clear\"\n onClick={handleClearInput}\n >\n <Icon source=\"close\" size={16} />\n </div>\n )}\n </div>\n </Combobox>\n )\n}\n\nconst wrappedComponent = withFieldLabelAndHint(Autocomplete)\nwrappedComponent.displayName = \"Autocomplete\"\n\nexport { wrappedComponent as Autocomplete }\n"],"names":["classNames"],"mappings":";;;;;;;AAkDA,SAAS,mBAAmB,CAC1B,KAAyB,EACzB,IAAY,EACZ,SAAiB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form/Autocomplete/index.tsx"],"sourcesContent":["import React, { useEffect, useRef, ElementType } from \"react\"\nimport { useState } from \"react\"\nimport classNames from \"classnames\"\n\nimport {\n Combobox,\n ComboboxInput,\n ComboboxPopover,\n ComboboxList,\n ComboboxOption,\n ComboboxOptionText,\n} from \"@reach/combobox\"\n\nimport { Icon, IconSources } from \"../../Icon\"\n\nimport { withFieldLabelAndHint } from \"../field\"\nimport { TextInputWrapper } from \"../TextInput\"\nimport { FormElement } from \"../form\"\n\nexport interface AutocompleteItem {\n [x: string]: any\n}\n\ntype ComboboxPopoverType = ElementType<\"div\"> & HTMLDivElement\ntype ComboboxOptionType = HTMLLIElement & React.ElementType<\"li\">\ntype ComboboxOptionMouseEventType = React.MouseEvent<\n ComboboxOptionType,\n MouseEvent\n>\n\ntype Props = {\n icon?: IconSources\n items: (AutocompleteItem | string)[]\n minQueryLength?: number\n autoFilter?: boolean\n selectedItem?: AutocompleteItem\n focusOnInit?: boolean\n autocomplete?: boolean\n valueKey?: string\n inputRef?: React.RefObject<HTMLInputElement>\n autocompleteRef?: React.RefObject<HTMLDivElement>\n onKeyDown?: (event: React.KeyboardEvent<HTMLElement>) => void\n onBlur?: (event: React.FocusEvent<HTMLInputElement>) => void\n onFocus?: (event: React.FocusEvent<HTMLInputElement>) => void\n onQueryChange?: (term: string) => void\n onSelectItem?: (item: AutocompleteItem, term: string) => boolean\n renderItem?: (item: AutocompleteItem, term: string) => React.ReactNode\n} & FormElement &\n React.InputHTMLAttributes<HTMLInputElement>\n\nfunction filterMatchingItems(\n items: AutocompleteItem[],\n term: string,\n minLength: number,\n valueKey: string\n) {\n const [matchingItems, setMatchingItems] = useState<AutocompleteItem[]>([])\n\n useEffect(() => {\n term.length >= minLength\n ? setMatchingItems(\n items.filter((item: AutocompleteItem) => {\n return item[valueKey].toLowerCase().indexOf(term.toLowerCase()) > -1\n })\n )\n : setMatchingItems([])\n }, [items, term, valueKey])\n\n return matchingItems\n}\n\nfunction sanitizeItems(items: (AutocompleteItem | string)[], valueKey: string) {\n const [sanitizedItems, setSanitizedItems] = useState<AutocompleteItem[]>([])\n useEffect(() => {\n setSanitizedItems(\n items.map((item) =>\n typeof item === \"string\" ? { [valueKey]: item } : item\n )\n )\n }, [items])\n return sanitizedItems\n}\n\nfunction Autocomplete({\n id,\n icon,\n status,\n items,\n selectedItem,\n autoFilter = true,\n minQueryLength = 1,\n focusOnInit = false,\n onKeyDown,\n onFocus,\n onBlur,\n onQueryChange,\n onSelectItem,\n renderItem,\n inputRef,\n autocompleteRef,\n valueKey = \"value\",\n ...inputProps\n}: Props) {\n const [term, setTerm] = useState(\"\")\n\n const [hasFocus, setHasFocus] = useState(false)\n\n let ignoreFocus = false // extra flag to ignore programmatical focus triggered by click on item\n\n const results = autoFilter\n ? filterMatchingItems(\n sanitizeItems(items, valueKey),\n term,\n minQueryLength,\n valueKey\n )\n : sanitizeItems(items, valueKey)\n\n const comboboxEl = autocompleteRef || useRef<HTMLDivElement>(null)\n\n const inputEl = inputRef || useRef<HTMLInputElement>(null)\n\n const popoverEl = useRef<ComboboxPopoverType>(null)\n\n const giveInputFocus = () => {\n inputEl.current && inputEl.current.focus()\n }\n\n const isMounted = useRef(true)\n const forceIdTimer = useRef<any>()\n const focusTimer = useRef<any>()\n const blurTimer = useRef<any>()\n const clearInputTimer = useRef<any>()\n\n function forceId() {\n // id is overriden by Reach ui Combobox\n forceIdTimer.current = setTimeout(() => {\n id && inputEl.current && inputEl.current.setAttribute(\"id\", id)\n })\n }\n\n useEffect(() => {\n // on mount ...\n focusOnInit && giveInputFocus()\n\n return () => {\n isMounted.current = false\n forceIdTimer.current && clearTimeout(forceIdTimer.current)\n focusTimer.current && clearTimeout(focusTimer.current)\n blurTimer.current && clearTimeout(blurTimer.current)\n clearInputTimer.current && clearTimeout(clearInputTimer.current)\n }\n }, [])\n\n useEffect(() => {\n forceId()\n }, [id])\n\n useEffect(() => {\n setTerm(selectedItem ? \"\" + selectedItem[valueKey] : \"\")\n }, [selectedItem])\n\n const handleFocus = (event: React.FocusEvent<HTMLInputElement>) => {\n !ignoreFocus && onFocus && onFocus(event)\n ignoreFocus = false\n focusTimer.current = setTimeout(() => {\n // required by \"forceDisplayResults\" mechanism\n isMounted.current && setHasFocus(true)\n }, 100)\n }\n\n const handleBlur = (event: React.FocusEvent<HTMLInputElement>) => {\n // blur interceptor required by \"forceDisplayResults\" mechanism\n onBlur && onBlur(event)\n blurTimer.current = setTimeout(() => {\n isMounted.current && setHasFocus(false)\n }, 100)\n }\n\n const handleChange = (event: React.FocusEvent<HTMLInputElement>) => {\n const inputValue = (event.target as HTMLInputElement).value\n if (inputValue.trim().length || term.length) {\n // to prevent starting with a space character\n setTerm(inputValue)\n onQueryChange && onQueryChange(inputValue)\n }\n }\n\n const handleClearInput = () => {\n setTerm(\"\")\n onQueryChange && onQueryChange(\"\")\n\n clearInputTimer.current = setTimeout(giveInputFocus) //timeout to trigger openOnFocus\n }\n\n const handleSelectItem = (\n item: AutocompleteItem,\n e: ComboboxOptionMouseEventType | React.KeyboardEvent<HTMLElement>\n ) => {\n // item click interceptor to enable custom select cancellation\n const processSelection = onSelectItem\n ? onSelectItem(item, term) !== false\n : true\n\n if (processSelection) {\n setTerm(item[valueKey])\n } else if (e) {\n e.preventDefault()\n ignoreFocus = true\n giveInputFocus()\n }\n }\n\n const handleKeyDown = (e: React.KeyboardEvent<HTMLElement>) => {\n onKeyDown && onKeyDown(e)\n\n // ENTER key down interceptor to enable custom select cancellation\n const KEY_CODE_ENTER = 13\n\n // BACKSPACE key down interceptor to synchonize react input value and dom input value in some edge case (Comnbobox autocomplete = true)\n const KEY_CODE_BACKSPACE = 8\n\n if (e.keyCode === KEY_CODE_ENTER) {\n if (!popoverEl.current) return\n\n const options = Array.from(\n popoverEl.current.querySelectorAll(\"[data-reach-combobox-option]\")\n )\n\n const selectedItemIndex = options.findIndex(\n (el) => el.getAttribute(\"aria-selected\") === \"true\"\n )\n\n selectedItemIndex >= 0 && handleSelectItem(results[selectedItemIndex], e)\n } else if (e.keyCode === KEY_CODE_BACKSPACE) {\n if (!inputEl.current) return\n if (inputEl.current.value.slice(0, -1) === term) {\n setTerm(inputEl.current.value)\n }\n }\n }\n\n const shouldDisplayItemsOnEmptyQuery = () => {\n return !autoFilter && results.length > 0 && term.length === 0 && hasFocus\n }\n\n const handleMouseDown = (\n item: AutocompleteItem,\n e: ComboboxOptionMouseEventType\n ) => {\n // In a specific case, we force the popover to display (results available, empty input using backspace)\n // But doing so, reach ui component is not ready for this case and will raise an error\n // We need to prevent the error and to force the selection\n if (\n shouldDisplayItemsOnEmptyQuery() &&\n popoverEl.current &&\n popoverEl.current.getAttribute(\"hidden\") != null\n ) {\n e.preventDefault() // it will prevent reach ui combobox to raise an error\n handleSelectItem(item, e) // we force the selection to be processed\n }\n }\n\n return (\n <Combobox\n className={classNames(\"cobalt-Autocomplete\", {\n \"cobalt-Autocomplete--forceDisplayResults\":\n shouldDisplayItemsOnEmptyQuery(), // Combobox Component, by design, hide the popover when the input is empty (on change) even if there are some results.\n })}\n as=\"div\"\n openOnFocus={true}\n ref={comboboxEl}\n >\n {results.length > 0 && (\n <ComboboxPopover\n className=\"cobalt-Autocomplete__popover\"\n portal={false}\n ref={popoverEl}\n >\n <ComboboxList\n className=\"cobalt-Autocomplete__list\"\n aria-label=\"Autocomplete option\"\n >\n {results.map((item, index) => (\n <ComboboxOption\n className=\"cobalt-Autocomplete__item\"\n key={index}\n value={item[valueKey]}\n onMouseDown={(e: ComboboxOptionMouseEventType) => {\n handleMouseDown(item, e)\n }}\n onClick={(e: ComboboxOptionMouseEventType) => {\n handleSelectItem(item, e)\n }}\n >\n {renderItem ? (\n renderItem(item, term)\n ) : (\n <span className=\"cobalt-Autocomplete__item-wrapper\">\n {icon && (\n <span className=\"cobalt-Autocomplete__item-icon\">\n <Icon source={icon} color=\"accent\" />\n </span>\n )}\n\n <span className=\"cobalt-Autocomplete__item-value\">\n <ComboboxOptionText />\n </span>\n </span>\n )}\n </ComboboxOption>\n ))}\n </ComboboxList>\n </ComboboxPopover>\n )}\n <div className=\"cobalt-Autocomplete__input-wrapper\">\n <TextInputWrapper\n icon={icon}\n status={status}\n render={(className) => {\n return (\n <ComboboxInput\n {...inputProps}\n autoComplete=\"off\"\n autoCorrect=\"off\"\n autoCapitalize=\"off\"\n spellCheck={false}\n aria-label=\"autocomplete input\"\n type=\"text\"\n value={term}\n onChange={handleChange}\n onBlur={handleBlur}\n onFocus={handleFocus}\n onKeyDown={handleKeyDown}\n ref={inputEl}\n className={className}\n />\n )\n }}\n />\n\n {term && (\n <div\n className=\"cobalt-Autocomplete__clear-button\"\n role=\"clear\"\n onClick={handleClearInput}\n >\n <Icon source=\"close\" size={16} />\n </div>\n )}\n </div>\n </Combobox>\n )\n}\n\nconst wrappedComponent = withFieldLabelAndHint(Autocomplete)\nwrappedComponent.displayName = \"Autocomplete\"\n\nexport { wrappedComponent as Autocomplete }\n"],"names":["classNames"],"mappings":";;;;;;;AAkDA,SAAS,mBAAmB,CAC1B,KAAyB,EACzB,IAAY,EACZ,SAAiB,EACjB,QAAgB,EAAA;IAEhB,MAAM,CAAC,aAAa,EAAE,gBAAgB,CAAC,GAAG,QAAQ,CAAqB,EAAE,CAAC,CAAA;IAE1E,SAAS,CAAC,MAAK;QACb,IAAI,CAAC,MAAM,IAAI,SAAS;cACpB,gBAAgB,CACd,KAAK,CAAC,MAAM,CAAC,CAAC,IAAsB,KAAI;AACtC,gBAAA,OAAO,IAAI,CAAC,QAAQ,CAAC,CAAC,WAAW,EAAE,CAAC,OAAO,CAAC,IAAI,CAAC,WAAW,EAAE,CAAC,GAAG,CAAC,CAAC,CAAA;AACtE,aAAC,CAAC,CACH;AACH,cAAE,gBAAgB,CAAC,EAAE,CAAC,CAAA;KACzB,EAAE,CAAC,KAAK,EAAE,IAAI,EAAE,QAAQ,CAAC,CAAC,CAAA;AAE3B,IAAA,OAAO,aAAa,CAAA;AACtB,CAAC;AAED,SAAS,aAAa,CAAC,KAAoC,EAAE,QAAg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EAC/B,IAAI,EAAC,MAAM,EACX,KAAK,EAAE,IAAI,EACX,QAAQ,EAAE,YAAY,EACtB,MAAM,EAAE,UAAU,EAClB,OAAO,EAAE,WAAW,EACpB,SAAS,EAAE,aAAa,EACxB,GAAG,EAAE,OAAO,EACZ,SAAS,EAAE,SAAS,EACpB,CAAA,EACH;AACH,iBAAC,EACD,CAAA;AAED,YAAA,IAAI,KACH,KACE,CAAA,aAAA,CAAA,KAAA,EAAA,EAAA,SAAS,EAAC,mCAAmC,EAC7C,IAAI,EAAC,OAAO,EACZ,OAAO,EAAE,gBAAgB,EAAA;AAEzB,gBAAA,KAAA,CAAA,aAAA,CAAC,IAAI,EAAA,EAAC,MAAM,EAAC,OAAO,EAAC,IAAI,EAAE,EAAE,GAAI,CAC7B,CACP,CACG,CACG,EACZ;AACH,CAAC;AAED,MAAM,gBAAgB,GAAG,qBAAqB,CAAC,YAAY,EAAC;AAC5D,gBAAgB,CAAC,WAAW,GAAG,cAAc;;;;"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@drivy/cobalt",
3
- "version": "0.29.1",
3
+ "version": "0.30.0",
4
4
  "description": "Opinionated design system for Drivy's projects.",
5
5
  "main": "src/index.js",
6
6
  "types": "types/index.d.ts",
@@ -34,10 +34,8 @@
34
34
  pointer-events: auto;
35
35
 
36
36
  &--info {
37
- // TOFIX: there is no matching semantic color for this case
38
- color: color(white);
39
-
40
- background-color: color(graphite);
37
+ @include bg-color(info);
38
+ @include text-color(info);
41
39
  }
42
40
 
43
41
  &--success {
@@ -26,8 +26,7 @@
26
26
  svg,
27
27
  use,
28
28
  g {
29
- // TOFIX: find a way to use new colors here
30
- fill: rgba(color(graphite), 0.5);
29
+ @include fill-color(subdued);
31
30
  }
32
31
  }
33
32
  }
@@ -46,7 +46,6 @@
46
46
  white-space: normal;
47
47
 
48
48
  border-radius: border-radius(md);
49
- box-shadow: 0 2px 8px 0 rgba(#000, 0.08);
50
49
 
51
50
  cursor: pointer;
52
51
  user-select: none;
@@ -1,13 +1,9 @@
1
1
  @use "sass:math";
2
2
 
3
3
  .cobalt-CalendarRangePicker {
4
- // TOFIX change it to AccentAlt color
5
- $calendar-range-day-color: lighten(color(purple, light), 29);
6
- $calendar-selected-day-invalid-color: color(red);
7
- // TOFIX change it to ErrorAlt color
8
- $calendar-range-day-invalid-color: lighten(color(red), 20);
9
- // TOFIX find a semantic color equivalent
10
- $calendar-out-of-range-color: darken($calendar-range-day-invalid-color, 8);
4
+ $calendar-range-day-color: var(--c-background-accentAlt);
5
+ $calendar-range-day-invalid-color: var(--c-background-errorAlt);
6
+ $calendar-out-of-range-color: var(--c-background-error);
11
7
 
12
8
  $calendar-day-inner-height: 24px;
13
9
  $calendar-day-padding: 6px;
@@ -45,7 +41,7 @@
45
41
 
46
42
  border-radius: 50%;
47
43
 
48
- box-shadow: rgba(176, 26, 167, 0.4) 0 2px 6px 0;
44
+ box-shadow: var(--c-background-accentAlt) 0 2px 6px 0;
49
45
  }
50
46
 
51
47
  position: relative;
@@ -59,9 +55,8 @@
59
55
  }
60
56
 
61
57
  &__month {
58
+ @include bg-color(secondary);
62
59
  flex: 1;
63
-
64
- background-color: color(white);
65
60
  }
66
61
 
67
62
  &__month-header {
@@ -92,11 +87,11 @@
92
87
  }
93
88
 
94
89
  &__month__day-header {
90
+ @include text-color(subdued);
95
91
  flex: 1;
96
92
 
97
93
  text-align: center;
98
94
  text-transform: capitalize;
99
- color: color(grey, dark);
100
95
  font-weight: 400;
101
96
  font-size: 14px;
102
97
  }
@@ -129,7 +124,7 @@
129
124
  }
130
125
 
131
126
  &--today {
132
- color: color(purple);
127
+ @include text-color(accent);
133
128
  font-weight: 600;
134
129
  }
135
130
 
@@ -140,8 +135,7 @@
140
135
  }
141
136
 
142
137
  &--disabled {
143
- color: color(grey);
144
-
138
+ @include text-color(subdued);
145
139
  cursor: auto;
146
140
  }
147
141
 
@@ -178,7 +172,8 @@
178
172
  .cobalt-CalendarRangePicker__day-inner:before {
179
173
  @include start-end-day;
180
174
 
181
- box-shadow: white 0 0 0 2px, rgb(176, 26, 167) 0 0 0 4px;
175
+ box-shadow: var(--c-background-secondary) 0 0 0 2px,
176
+ var(--c-background-accent) 0 0 0 4px;
182
177
  }
183
178
 
184
179
  // start/end day content when the other one is currently edited + today
@@ -188,8 +183,8 @@
188
183
  &--endDay.cobalt-CalendarRangePicker__day--today:not(
189
184
  &--startDay
190
185
  ).cobalt-CalendarRangePicker__day--subdued {
186
+ @include text-color(accent);
191
187
  font-weight: 600;
192
- color: color(purple);
193
188
  }
194
189
 
195
190
  // not today
@@ -199,8 +194,8 @@
199
194
  &--endDay:not(&--startDay):not(
200
195
  &--today
201
196
  ).cobalt-CalendarRangePicker__day--subdued {
197
+ @include text-color(base);
202
198
  font-weight: inherit;
203
- color: black;
204
199
  }
205
200
 
206
201
  // start/end day background (circle) when the other one is currently edited
@@ -305,7 +300,7 @@
305
300
  &--endDay .cobalt-CalendarRangePicker__day-inner:after {
306
301
  @include bg-color(error);
307
302
 
308
- box-shadow: rgba($calendar-selected-day-invalid-color, 0.4) 0 2px 6px 0;
303
+ box-shadow: var(--c-background-errorAlt) 0 2px 6px 0;
309
304
  }
310
305
 
311
306
  // invalid start/end day background (circle) when the other one is currently edited
@@ -38,24 +38,22 @@ $daySize: spacing(md);
38
38
  border-radius: math.div($daySize, 2);
39
39
 
40
40
  &--disabled {
41
- @include bg-color(disabled);
41
+ @include bg-color(neutral);
42
+ @include text-color(subdued);
42
43
  }
43
44
 
44
45
  &--highlighted {
45
46
  @include text-color(inversed);
46
-
47
- // TOFIX find a semantic color equivalent
48
- background-color: color(turquoise);
47
+ @include bg-color(connect);
49
48
  }
50
49
 
51
50
  &--semi-highlighted {
52
- // TOFIX find a semantic color equivalent
53
- background-color: lighten(color(turquoise), 30);
51
+ @include bg-color(connectAlt);
54
52
  }
55
53
 
56
54
  &--past {
57
- // TOFIX find a semantic color equivalent
58
- color: color(grey);
55
+ @include text-color(subdued);
56
+ opacity: 0.4;
59
57
  }
60
58
 
61
59
  &:not(:first-child) {
@@ -1,20 +1,27 @@
1
1
  .cobalt- {
2
- $card-border-radius: border-radius(base);
2
+ $card-border-radius: border-radius(xl);
3
3
  // deprecated
4
4
  $legacy-card-padding-tight: 12px;
5
5
 
6
6
  &Card {
7
7
  @include bg-color(secondary);
8
+ @include border(base);
8
9
  width: 100%;
9
10
 
10
11
  border-radius: $card-border-radius;
11
12
 
12
- box-shadow: elevation(base);
13
+ &--legacy {
14
+ border: 0;
13
15
 
14
- &--flattened {
15
- @include border(base);
16
+ box-shadow: elevation(base);
17
+ }
16
18
 
17
- box-shadow: none;
19
+ &--responsive {
20
+ @include breakpoint($until: sm) {
21
+ border-radius: 0;
22
+ border-left-width: 0;
23
+ border-right-width: 0;
24
+ }
18
25
  }
19
26
  }
20
27
 
@@ -63,11 +70,14 @@
63
70
  padding-top: $legacy-card-padding-tight - 1px;
64
71
  }
65
72
 
66
- &Card > .cobalt-Card__Section:first-of-type {
73
+ // first-of-class, source: https://stackoverflow.com/questions/2717480/css-selector-for-first-element-with-class
74
+ &Card
75
+ > .cobalt-Card__Section:not(.cobalt-Card__Section ~ .cobalt-Card__Section) {
67
76
  border-top-left-radius: $card-border-radius;
68
77
  border-top-right-radius: $card-border-radius;
69
78
  }
70
79
 
80
+ // No last-of-class hack found for now
71
81
  &Card > .cobalt-Card__Section:last-of-type {
72
82
  border-bottom-right-radius: $card-border-radius;
73
83
  border-bottom-left-radius: $card-border-radius;
@@ -13,10 +13,8 @@
13
13
  box-shadow: elevation(lg);
14
14
 
15
15
  &--info {
16
- // TOFIX: there is no matching semantic color for this case
17
- color: color(white);
18
-
19
- background-color: color(graphite);
16
+ @include bg-color(info);
17
+ @include text-color(info);
20
18
  }
21
19
 
22
20
  &--success {
@@ -1,14 +1,6 @@
1
1
  @import "@reach/combobox/styles.css";
2
2
 
3
3
  .cobalt-Autocomplete {
4
- $border-color: color(indigo);
5
- $border-separator-popover-color: color(grey, light);
6
- $selected-item-color: color(purple);
7
- $selected-item-background-color: color(grey, lighter);
8
- $selected-item-background-darken-color: darken(
9
- $selected-item-background-color,
10
- 2
11
- );
12
4
  $autocomplete-popover-zindex: 2147483647; //max z-index value
13
5
 
14
6
  @include form-field-container;
@@ -33,6 +25,7 @@
33
25
  }
34
26
 
35
27
  &__popover {
28
+ @include border(accent, 2);
36
29
  position: absolute;
37
30
 
38
31
  z-index: $autocomplete-popover-zindex;
@@ -47,14 +40,10 @@
47
40
  border-bottom-right-radius: 4px;
48
41
  border-bottom-left-radius: 4px;
49
42
 
50
- border: 2px solid $border-color;
51
-
52
43
  background-color: color(white);
53
44
 
54
- box-shadow: 0 2px 2px 0 rgba($border-color, 0.06),
55
- 0 6px 6px 0 rgba($border-color, 0.04),
56
- 0 8px 8px 0 rgba($border-color, 0.06),
57
- inset 0 1px 0 0 $border-separator-popover-color;
45
+ box-shadow: 0 2px 2px 0 rgba(0, 0, 0, 0.06), 0 6px 6px 0 rgba(0, 0, 0, 0.04),
46
+ 0 8px 8px 0 rgba(0, 0, 0, 0.06);
58
47
 
59
48
  border-top-width: 0;
60
49
 
@@ -82,6 +71,8 @@
82
71
  }
83
72
 
84
73
  &__item {
74
+ @include bg-color(secondaryInteractive);
75
+
85
76
  width: 100%;
86
77
  display: flex;
87
78
  padding: 0;
@@ -91,19 +82,17 @@
91
82
 
92
83
  &__item:hover,
93
84
  &__item[aria-selected="true"] {
94
- color: $selected-item-color;
85
+ @include text-color(accentAlt);
95
86
 
96
87
  cursor: pointer;
97
88
 
98
- background-color: $selected-item-background-color;
99
-
100
89
  .cobalt-Icon {
101
- fill: $selected-item-color;
90
+ @include semantic-color(accent, icon, fill);
102
91
  }
103
92
  }
104
93
 
105
94
  &__item[aria-selected="true"]:hover {
106
- background-color: $selected-item-background-darken-color;
95
+ @include bg-color(accentAlt);
107
96
  }
108
97
 
109
98
  &__popover .cobalt-Autocomplete__item-icon {
@@ -133,12 +122,12 @@
133
122
  }
134
123
 
135
124
  &__item-wrapper--disabled {
136
- color: color(grey, dark);
125
+ @include text-color(subdued);
137
126
 
138
127
  cursor: auto;
139
128
 
140
129
  .cobalt-Icon {
141
- fill: color(grey, dark) !important;
130
+ fill: var(--c-icon-subdued) !important;
142
131
  }
143
132
  }
144
133
 
@@ -43,7 +43,6 @@
43
43
  line-height: $height - 2px * 2;
44
44
 
45
45
  border-radius: math.div($height, 2);
46
- box-shadow: 0 2px 6px 0 rgba(#000, 0.12);
47
46
 
48
47
  transition: $animation-duration;
49
48
 
@@ -88,7 +87,7 @@
88
87
  &__Input:checked + #{ $self }__Label {
89
88
  @include bg-color(accentAlt);
90
89
  @include text-color(accentAlt);
91
- border-color: transparent;
90
+ @include border(accentAlt, 2);
92
91
  }
93
92
 
94
93
  &--with-icon {
@@ -5,17 +5,13 @@
5
5
  $checkbox-checkmark-size: 18px;
6
6
 
7
7
  @include text-color(base);
8
+ @include c-text-body-md;
8
9
 
9
10
  position: relative;
10
11
 
11
12
  margin-bottom: spacing(xs);
12
13
  display: block;
13
14
 
14
- font-weight: 400;
15
- font-family: font-family(base);
16
- font-size: font-size(body);
17
- line-height: line-height(body);
18
-
19
15
  &__Input {
20
16
  position: absolute;
21
17
 
@@ -30,14 +30,5 @@
30
30
  &--error {
31
31
  @include text-color(error);
32
32
  }
33
-
34
- a {
35
- @include text-color(accentInteractive);
36
- text-decoration: none;
37
- }
38
-
39
- a:hover {
40
- text-decoration: underline;
41
- }
42
33
  }
43
34
  }
@@ -9,7 +9,7 @@
9
9
  --visual-radio-size: 18px;
10
10
 
11
11
  .cobalt-radio-with-details__inner {
12
- @include border(strongInteractive);
12
+ @include border(baseInteractive);
13
13
  @include text-color(base);
14
14
  @include bg-color(secondary);
15
15
  height: 100%;
@@ -49,7 +49,7 @@
49
49
  }
50
50
 
51
51
  .cobalt-radio-with-details__description {
52
- @include c-text-body-md;
52
+ @include c-text-body-sm;
53
53
  @include text-color(subdued);
54
54
 
55
55
  transition: color 150ms ease-in-out;
@@ -3,9 +3,6 @@
3
3
  @include bg-color(secondary);
4
4
  padding: spacing(sm);
5
5
 
6
- // FIXME: remove when releasing semantics color
7
- background-color: fade-out(color(purple), 0.92);
8
-
9
6
  border-radius: border-radius(xl);
10
7
 
11
8
  &__title {
@@ -24,13 +24,12 @@
24
24
  }
25
25
 
26
26
  &Icon--contained {
27
- @include bg-color(secondary);
27
+ @include bg-color(neutralAlt);
28
28
  height: 40px;
29
29
  width: 40px;
30
30
  padding: math.div(40px - 24px, 2);
31
31
 
32
32
  border-radius: 50%;
33
- box-shadow: elevation(base);
34
33
  }
35
34
 
36
35
  &Icon--size16 {
@@ -9,6 +9,10 @@
9
9
  padding: spacing(sm);
10
10
 
11
11
  border-radius: border-radius(lg);
12
+
13
+ a {
14
+ color: inherit;
15
+ }
12
16
  }
13
17
 
14
18
  &Note--fullWidth {
@@ -31,8 +31,7 @@
31
31
  }
32
32
 
33
33
  .cobalt-photo-dropzone--dragging {
34
- // FIXME NEW COLORS: this background doesn't match any semantic color
35
- background-color: #f6e5f5;
34
+ @include bg-color(accentAlt);
36
35
 
37
36
  transition: background-color 0.25s;
38
37
 
@@ -41,7 +41,7 @@
41
41
  }
42
42
 
43
43
  &TabScroller--underlined:after {
44
- @include fill-bg-color(base);
44
+ @include semantic-color(base, stroke, background);
45
45
  position: absolute;
46
46
  bottom: 0;
47
47