@drivy/cobalt 0.37.4 → 0.39.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.
@@ -3,6 +3,8 @@ import cx from 'classnames';
3
3
  import { withFieldLabelAndHint } from './field.js';
4
4
  import DefaultButton from '../Buttons/DefaultButton/index.js';
5
5
 
6
+ const AUTO_CHANGE_TIMEOUT_IN_MS = 750;
7
+ const AUTO_CHANGE_INTERVAL_IN_MS = 150;
6
8
  const enforceInRange = (value, min, max) => {
7
9
  let enforcedValue = value;
8
10
  if (typeof max !== "undefined") {
@@ -16,6 +18,8 @@ const enforceInRange = (value, min, max) => {
16
18
  class Stepper extends PureComponent {
17
19
  constructor(props) {
18
20
  super(props);
21
+ this.timeout = null;
22
+ this.interval = null;
19
23
  this.onDecrement = () => {
20
24
  (this.props.min !== null || this.state.value > this.props.min) &&
21
25
  this.changeValue(parseFloat((this.state.value - this.props.step).toFixed(10)));
@@ -24,6 +28,21 @@ class Stepper extends PureComponent {
24
28
  (this.props.max !== null || this.state.value < this.props.max) &&
25
29
  this.changeValue(parseFloat((this.state.value + this.props.step).toFixed(10)));
26
30
  };
31
+ this.onPointerDown = (callback) => {
32
+ callback();
33
+ this.timeout && clearTimeout(this.timeout);
34
+ this.timeout = setTimeout(() => {
35
+ this.interval && clearInterval(this.interval);
36
+ this.interval = setInterval(callback, AUTO_CHANGE_INTERVAL_IN_MS);
37
+ }, AUTO_CHANGE_TIMEOUT_IN_MS);
38
+ };
39
+ this.onPointerUp = () => {
40
+ if (this.interval) {
41
+ clearInterval(this.interval);
42
+ this.interval = null;
43
+ }
44
+ this.timeout && clearTimeout(this.timeout);
45
+ };
27
46
  this.changeValue = (value) => {
28
47
  this.setState({
29
48
  value: enforceInRange(value, this.props.min, this.props.max),
@@ -36,6 +55,8 @@ class Stepper extends PureComponent {
36
55
  this.onDecrement = this.onDecrement.bind(this);
37
56
  this.onIncrement = this.onIncrement.bind(this);
38
57
  this.changeValue = this.changeValue.bind(this);
58
+ this.onPointerDown = this.onPointerDown.bind(this);
59
+ this.onPointerUp = this.onPointerUp.bind(this);
39
60
  this.state = {
40
61
  value: enforceInRange(props.value, props.min, props.max),
41
62
  };
@@ -56,11 +77,11 @@ class Stepper extends PureComponent {
56
77
  "cobalt-Stepper--error": status === "error",
57
78
  }) },
58
79
  React.createElement("div", { className: "cobalt-Stepper__Wrapper" },
59
- React.createElement(DefaultButton, { className: "cobalt-Stepper__ActionButton", disabled: disabled || this.state.value === min, onClick: this.onDecrement, type: "button" }, "-"),
80
+ React.createElement(DefaultButton, { className: "cobalt-Stepper__ActionButton", disabled: disabled || this.state.value === min, onPointerDown: () => this.onPointerDown(this.onDecrement), onPointerUp: this.onPointerUp, onPointerLeave: this.onPointerUp, type: "button" }, "-"),
60
81
  React.createElement("div", { className: "cobalt-Stepper__ContentWrapper" },
61
82
  children ? children(this.state.value) : this.state.value,
62
83
  React.createElement("input", { type: "hidden", name: name, value: this.state.value })),
63
- React.createElement(DefaultButton, { className: "cobalt-Stepper__ActionButton", disabled: disabled || this.state.value === max, onClick: this.onIncrement, type: "button" }, "+"))));
84
+ React.createElement(DefaultButton, { className: "cobalt-Stepper__ActionButton", disabled: disabled || this.state.value === max, onPointerDown: () => this.onPointerDown(this.onIncrement), onPointerUp: this.onPointerUp, onPointerLeave: this.onPointerUp, type: "button" }, "+"))));
64
85
  }
65
86
  }
66
87
  const wrappedComponent = withFieldLabelAndHint(Stepper);
@@ -1 +1 @@
1
- {"version":3,"file":"Stepper.js","sources":["../../../src/components/Form/Stepper.tsx"],"sourcesContent":["import React, { PureComponent } from \"react\"\nimport classNames from \"classnames\"\nimport { FormElement } from \"./form\"\nimport { withFieldLabelAndHint } from \"./field\"\nimport DefaultButton from \"../Buttons/DefaultButton\"\n\nconst enforceInRange = (\n value: number,\n min: number | undefined,\n max: number | undefined\n) => {\n let enforcedValue = value\n if (typeof max !== \"undefined\") {\n enforcedValue = Math.min(enforcedValue, max)\n }\n if (typeof min !== \"undefined\") {\n enforcedValue = Math.max(enforcedValue, min)\n }\n return enforcedValue\n}\n\ntype Props = {\n value: number\n name?: string\n disabled?: boolean\n min?: number\n max?: number\n step: number\n onChange?: (value: number) => void\n children?: (value: number) => React.ReactNode\n} & FormElement\n\ntype State = {\n value: number\n}\n\nclass Stepper extends PureComponent<Props, State> {\n constructor(props: Props) {\n super(props)\n\n if (props.step < 0)\n throw new Error(\"Incorrect step value. Can't be below zero\")\n\n this.onDecrement = this.onDecrement.bind(this)\n this.onIncrement = this.onIncrement.bind(this)\n this.changeValue = this.changeValue.bind(this)\n\n this.state = {\n value: enforceInRange(props.value, props.min, props.max),\n }\n }\n\n componentDidUpdate(_prevProps: Props, prevState: State) {\n if (prevState.value !== this.state.value) {\n this.changeValue(this.state.value)\n } else if (this.props.value !== this.state.value) {\n this.changeValue(this.props.value)\n }\n }\n\n onDecrement = () => {\n ;(this.props.min !== null || this.state.value > this.props.min) &&\n this.changeValue(\n parseFloat((this.state.value - this.props.step).toFixed(10))\n )\n }\n\n onIncrement = () => {\n ;(this.props.max !== null || this.state.value < this.props.max) &&\n this.changeValue(\n parseFloat((this.state.value + this.props.step).toFixed(10))\n )\n }\n\n changeValue = (value: number) => {\n this.setState(\n {\n value: enforceInRange(value, this.props.min, this.props.max),\n },\n () => {\n this.props.onChange && this.props.onChange(this.state.value)\n }\n )\n }\n\n render() {\n const { name, status, disabled, min, max, children } = this.props\n\n return (\n <div\n className={classNames(\"cobalt-Stepper\", {\n \"cobalt-Stepper--disabled\": disabled,\n \"cobalt-Stepper--success\": status === \"success\",\n \"cobalt-Stepper--error\": status === \"error\",\n })}\n >\n <div className=\"cobalt-Stepper__Wrapper\">\n <DefaultButton\n className=\"cobalt-Stepper__ActionButton\"\n disabled={disabled || this.state.value === min}\n onClick={this.onDecrement}\n type={\"button\"}\n >\n -\n </DefaultButton>\n <div className=\"cobalt-Stepper__ContentWrapper\">\n {children ? children(this.state.value) : this.state.value}\n <input type=\"hidden\" name={name} value={this.state.value} />\n </div>\n <DefaultButton\n className=\"cobalt-Stepper__ActionButton\"\n disabled={disabled || this.state.value === max}\n onClick={this.onIncrement}\n type={\"button\"}\n >\n +\n </DefaultButton>\n </div>\n </div>\n )\n }\n}\n\nconst wrappedComponent = withFieldLabelAndHint(Stepper)\nwrappedComponent.displayName = \"Stepper\"\n\nexport { wrappedComponent as Stepper }\n\ntype StepperMetaProps = {\n children: React.ReactNode\n}\nconst StepperMeta = ({ children }: StepperMetaProps) => {\n return <div className=\"cobalt-Stepper__Meta\">{children}</div>\n}\n\nexport { StepperMeta }\n"],"names":["classNames"],"mappings":";;;;;AAMA,MAAM,cAAc,GAAG,CACrB,KAAa,EACb,GAAuB,EACvB,GAAuB,KACrB;IACF,IAAI,aAAa,GAAG,KAAK,CAAA;AACzB,IAAA,IAAI,OAAO,GAAG,KAAK,WAAW,EAAE;QAC9B,aAAa,GAAG,IAAI,CAAC,GAAG,CAAC,aAAa,EAAE,GAAG,CAAC,CAAA;AAC7C,KAAA;AACD,IAAA,IAAI,OAAO,GAAG,KAAK,WAAW,EAAE;QAC9B,aAAa,GAAG,IAAI,CAAC,GAAG,CAAC,aAAa,EAAE,GAAG,CAAC,CAAA;AAC7C,KAAA;AACD,IAAA,OAAO,aAAa,CAAA;AACtB,CAAC,CAAA;AAiBD,MAAM,OAAQ,SAAQ,aAA2B,CAAA;AAC/C,IAAA,WAAA,CAAY,KAAY,EAAA;QACtB,KAAK,CAAC,KAAK,CAAC,CAAA;QAsBd,IAAW,CAAA,WAAA,GAAG,MAAK;AAChB,YAAA,CAAC,IAAI,CAAC,KAAK,CAAC,GAAG,KAAK,IAAI,IAAI,IAAI,CAAC,KAAK,CAAC,KAAK,GAAG,IAAI,CAAC,KAAK,CAAC,GAAG;gBAC5D,IAAI,CAAC,WAAW,CACd,UAAU,CAAC,CAAC,IAAI,CAAC,KAAK,CAAC,KAAK,GAAG,IAAI,CAAC,KAAK,CAAC,IAAI,EAAE,OAAO,CAAC,EAAE,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,GAAG,QAAQ,CAAC,IAAI,CAAC,KAAK,CAAC,KAAK,CAAC,GAAG,IAAI,CAAC,KAAK,CAAC,KAAK;AACzD,oBAAA,KAAA,CAAA,aAAA,CAAA,OAAA,EAAA,EAAO,IAAI,EAAC,QAAQ,EAAC,IAAI,EAAE,IAAI,EAAE,KAAK,EAAE,IAAI,CAAC,KAAK,CAAC,KAAK,GAAI,CACxD;AACN,gBAAA,KAAA,CAAA,aAAA,CAAC,aAAa,EAAA,EACZ,SAAS,EAAC,8BAA8B,EACxC,QAAQ,EAAE,QAAQ,IAAI,IAAI,CAAC,KAAK,CAAC,KAAK,KAAK,GAAG,EAC9C,OAAO,EAAE,IAAI,CAAC,WAAW,EACzB,IAAI,EAAE,QAAQ,EAAA,EAAA,GAAA,CAGA,CACZ,CACF,EACP;KACF;AACF,CAAA;AAED,MAAM,gBAAgB,GAAG,qBAAqB,CAAC,OAAO,EAAC;AACvD,gBAAgB,CAAC,WAAW,GAAG,SAAS,CAAA;AAOxC,MAAM,WAAW,GAAG,CAAC,EAAE,QAAQ,EAAoB,KAAI;AACrD,IAAA,OAAO,6BAAK,SAAS,EAAC,sBAAsB,EAAE,EAAA,QAAQ,CAAO,CAAA;AAC/D;;;;"}
1
+ {"version":3,"file":"Stepper.js","sources":["../../../src/components/Form/Stepper.tsx"],"sourcesContent":["import React, { PureComponent } from \"react\"\nimport classNames from \"classnames\"\nimport { FormElement } from \"./form\"\nimport { withFieldLabelAndHint } from \"./field\"\nimport DefaultButton from \"../Buttons/DefaultButton\"\n\nconst AUTO_CHANGE_TIMEOUT_IN_MS = 750\nconst AUTO_CHANGE_INTERVAL_IN_MS = 150\n\nconst enforceInRange = (\n value: number,\n min: number | undefined,\n max: number | undefined\n) => {\n let enforcedValue = value\n if (typeof max !== \"undefined\") {\n enforcedValue = Math.min(enforcedValue, max)\n }\n if (typeof min !== \"undefined\") {\n enforcedValue = Math.max(enforcedValue, min)\n }\n return enforcedValue\n}\n\ntype Props = {\n value: number\n name?: string\n disabled?: boolean\n min?: number\n max?: number\n step: number\n onChange?: (value: number) => void\n children?: (value: number) => React.ReactNode\n} & FormElement\n\ntype State = {\n value: number\n}\n\nclass Stepper extends PureComponent<Props, State> {\n constructor(props: Props) {\n super(props)\n\n if (props.step < 0)\n throw new Error(\"Incorrect step value. Can't be below zero\")\n\n this.onDecrement = this.onDecrement.bind(this)\n this.onIncrement = this.onIncrement.bind(this)\n this.changeValue = this.changeValue.bind(this)\n this.onPointerDown = this.onPointerDown.bind(this)\n this.onPointerUp = this.onPointerUp.bind(this)\n\n this.state = {\n value: enforceInRange(props.value, props.min, props.max),\n }\n }\n\n timeout: ReturnType<typeof setTimeout> | null = null\n interval: ReturnType<typeof setInterval> | null = null\n\n componentDidUpdate(_prevProps: Props, prevState: State) {\n if (prevState.value !== this.state.value) {\n this.changeValue(this.state.value)\n } else if (this.props.value !== this.state.value) {\n this.changeValue(this.props.value)\n }\n }\n\n onDecrement = () => {\n ;(this.props.min !== null || this.state.value > this.props.min) &&\n this.changeValue(\n parseFloat((this.state.value - this.props.step).toFixed(10))\n )\n }\n\n onIncrement = () => {\n ;(this.props.max !== null || this.state.value < this.props.max) &&\n this.changeValue(\n parseFloat((this.state.value + this.props.step).toFixed(10))\n )\n }\n\n onPointerDown = (callback: () => void) => {\n callback()\n this.timeout && clearTimeout(this.timeout)\n this.timeout = setTimeout(() => {\n this.interval && clearInterval(this.interval)\n this.interval = setInterval(callback, AUTO_CHANGE_INTERVAL_IN_MS)\n }, AUTO_CHANGE_TIMEOUT_IN_MS)\n }\n\n onPointerUp = () => {\n if (this.interval) {\n clearInterval(this.interval)\n this.interval = null\n }\n this.timeout && clearTimeout(this.timeout)\n }\n\n changeValue = (value: number) => {\n this.setState(\n {\n value: enforceInRange(value, this.props.min, this.props.max),\n },\n () => {\n this.props.onChange && this.props.onChange(this.state.value)\n }\n )\n }\n\n render() {\n const { name, status, disabled, min, max, children } = this.props\n\n return (\n <div\n className={classNames(\"cobalt-Stepper\", {\n \"cobalt-Stepper--disabled\": disabled,\n \"cobalt-Stepper--success\": status === \"success\",\n \"cobalt-Stepper--error\": status === \"error\",\n })}\n >\n <div className=\"cobalt-Stepper__Wrapper\">\n <DefaultButton\n className=\"cobalt-Stepper__ActionButton\"\n disabled={disabled || this.state.value === min}\n onPointerDown={() => this.onPointerDown(this.onDecrement)}\n onPointerUp={this.onPointerUp}\n onPointerLeave={this.onPointerUp}\n type={\"button\"}\n >\n -\n </DefaultButton>\n <div className=\"cobalt-Stepper__ContentWrapper\">\n {children ? children(this.state.value) : this.state.value}\n <input type=\"hidden\" name={name} value={this.state.value} />\n </div>\n <DefaultButton\n className=\"cobalt-Stepper__ActionButton\"\n disabled={disabled || this.state.value === max}\n onPointerDown={() => this.onPointerDown(this.onIncrement)}\n onPointerUp={this.onPointerUp}\n onPointerLeave={this.onPointerUp}\n type={\"button\"}\n >\n +\n </DefaultButton>\n </div>\n </div>\n )\n }\n}\n\nconst wrappedComponent = withFieldLabelAndHint(Stepper)\nwrappedComponent.displayName = \"Stepper\"\n\nexport { wrappedComponent as Stepper }\n\ntype StepperMetaProps = {\n children: React.ReactNode\n}\nconst StepperMeta = ({ children }: StepperMetaProps) => {\n return <div className=\"cobalt-Stepper__Meta\">{children}</div>\n}\n\nexport { StepperMeta }\n"],"names":["classNames"],"mappings":";;;;;AAMA,MAAM,yBAAyB,GAAG,GAAG,CAAA;AACrC,MAAM,0BAA0B,GAAG,GAAG,CAAA;AAEtC,MAAM,cAAc,GAAG,CACrB,KAAa,EACb,GAAuB,EACvB,GAAuB,KACrB;IACF,IAAI,aAAa,GAAG,KAAK,CAAA;AACzB,IAAA,IAAI,OAAO,GAAG,KAAK,WAAW,EAAE;QAC9B,aAAa,GAAG,IAAI,CAAC,GAAG,CAAC,aAAa,EAAE,GAAG,CAAC,CAAA;AAC7C,KAAA;AACD,IAAA,IAAI,OAAO,GAAG,KAAK,WAAW,EAAE;QAC9B,aAAa,GAAG,IAAI,CAAC,GAAG,CAAC,a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 <svg width="600" height="600" viewBox="0 0 600 600" fill="none" xmlns="http://www.w3.org/2000/svg">
2
+ <path fill-rule="evenodd" clip-rule="evenodd" d="M476 300C476 397.202 397.202 476 300 476C202.797 476 124 397.202 124 300C124 202.798 202.797 124 300 124C397.202 124 476 202.798 476 300ZM374.294 384.048L225.289 385.324C208.946 385.324 199.044 372.703 199.044 357.995C199.044 353.477 199.965 346.075 202.561 341.749L277.393 214.565C282.295 205.817 290.947 201.395 299.792 201.395C308.636 201.395 320.256 205.817 325.255 214.565L396.789 344.537C399.192 348.767 400.539 353.477 400.539 357.995C400.539 372.703 390.637 384.048 374.294 384.048ZM292.236 308.617C292.332 313.712 294.889 319.83 299.887 319.83C304.599 319.83 307.386 317.042 307.482 311.852C307.482 311.852 308.069 300.028 308.416 287.667C308.687 278 308.814 268.004 308.88 262.817C308.899 261.321 308.913 260.224 308.924 259.652C309.02 254.557 305.629 250.807 299.792 250.807C294.408 250.807 290.659 254.46 290.755 259.556C290.755 259.556 291.668 279.743 291.668 284.127C291.668 288.51 292.236 308.617 292.236 308.617ZM290.397 341.749C290.397 347.421 295.396 350.759 301.163 350.759C306.835 350.759 311.834 347.517 311.834 341.749C311.834 335.885 306.932 331.366 301.163 331.366C295.3 331.366 290.397 335.981 290.397 341.749Z" fill="#79A3F3"/>
3
+ </svg>
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@drivy/cobalt",
3
- "version": "0.37.4",
3
+ "version": "0.39.0",
4
4
  "description": "Opinionated design system for Drivy's projects.",
5
5
  "main": "src/index.js",
6
6
  "types": "types/index.d.ts",
@@ -35,7 +35,7 @@
35
35
  "date-fns": "2.30.0",
36
36
  "lodash.throttle": "4.1.1",
37
37
  "media-typer": "1.1.0",
38
- "nanoid": "5.0.1",
38
+ "nanoid": "5.0.3",
39
39
  "postcss": "8.4.31",
40
40
  "tailwindcss": "2.2.19",
41
41
  "tippy.js": "6.3.7"
@@ -53,25 +53,25 @@
53
53
  "@percy/storybook": "4.3.6",
54
54
  "@rollup/plugin-json": "6.0.1",
55
55
  "@rushstack/eslint-patch": "1.5.1",
56
- "@storybook/addon-essentials": "7.4.6",
57
- "@storybook/addons": "7.4.6",
58
- "@storybook/blocks": "7.4.6",
59
- "@storybook/react": "7.4.6",
60
- "@storybook/react-webpack5": "7.4.6",
56
+ "@storybook/addon-essentials": "7.5.3",
57
+ "@storybook/addons": "7.5.3",
58
+ "@storybook/blocks": "7.5.3",
59
+ "@storybook/react": "7.5.3",
60
+ "@storybook/react-webpack5": "7.5.3",
61
61
  "@svgr/cli": "7.0.0",
62
62
  "@testing-library/jest-dom": "5.17.0",
63
- "@testing-library/react": "14.0.0",
63
+ "@testing-library/react": "14.1.0",
64
64
  "@testing-library/react-hooks": "8.0.1",
65
65
  "@types/classnames": "2.3.1",
66
- "@types/jest": "29.5.5",
67
- "@types/lodash.throttle": "4.1.7",
68
- "@types/media-typer": "1.1.1",
66
+ "@types/jest": "29.5.8",
67
+ "@types/lodash.throttle": "4.1.9",
68
+ "@types/media-typer": "1.1.3",
69
69
  "@types/prettier": "3.0.0",
70
- "@types/react-dom": "18.2.11",
70
+ "@types/react-dom": "18.2.15",
71
71
  "autoprefixer": "10.4.16",
72
- "core-js": "3.33.0",
72
+ "core-js": "3.33.2",
73
73
  "css-loader": "6.8.1",
74
- "eslint": "8.51.0",
74
+ "eslint": "8.53.0",
75
75
  "eslint-plugin-storybook": "^0.6.15",
76
76
  "file-loader": "6.2.0",
77
77
  "jest": "29.7.0",
@@ -86,6 +86,7 @@
86
86
  "react-dom": "18.2.0",
87
87
  "react-syntax-highlighter": "15.5.0",
88
88
  "react-test-renderer": "18.2.0",
89
+ "react-textarea-autosize": "^8.5.3",
89
90
  "regenerator-runtime": "0.14.0",
90
91
  "remark-gfm": "^3.0.1",
91
92
  "rollup": "2.79.1",
@@ -93,15 +94,15 @@
93
94
  "rollup-plugin-postcss": "4.0.2",
94
95
  "rollup-plugin-svgo": "2.0.0",
95
96
  "rollup-plugin-typescript2": "0.36.0",
96
- "sass": "1.69.0",
97
+ "sass": "1.69.5",
97
98
  "sass-loader": "13.3.2",
98
99
  "sharp": "0.32.6",
99
100
  "sharp-cli": "4.1.1",
100
- "storybook": "7.4.6",
101
+ "storybook": "7.5.3",
101
102
  "style-loader": "3.3.3",
102
- "stylelint": "15.10.3",
103
+ "stylelint": "15.11.0",
103
104
  "svg2vectordrawable": "2.9.1",
104
- "svgo": "3.0.2",
105
+ "svgo": "3.0.3",
105
106
  "ts-jest": "29.1.1",
106
107
  "ts-node": "10.9.1",
107
108
  "typescript": "5.2.2"
@@ -46,6 +46,10 @@
46
46
  position: relative;
47
47
  top: 3px;
48
48
 
49
+ display: flex;
50
+ align-items: center;
51
+ justify-content: center;
52
+
49
53
  width: $radio-checkmark-size;
50
54
  height: $radio-checkmark-size;
51
55
 
@@ -56,10 +60,6 @@
56
60
  @include border(accent);
57
61
  @include bg-color(accentAlt);
58
62
 
59
- position: absolute;
60
-
61
- top: 3px;
62
- left: 3px;
63
63
  // Exception for radio inputs
64
64
  border-width: 5px;
65
65
 
@@ -76,13 +76,17 @@
76
76
  position: relative;
77
77
  top: 3px;
78
78
 
79
+ display: flex;
80
+
79
81
  flex: 0 0 auto;
82
+ align-items: center;
83
+ justify-content: center;
80
84
  width: var(--visual-radio-size);
81
85
  height: var(--visual-radio-size);
82
86
 
83
- border-radius: 50%;
84
-
85
87
  box-shadow: 0 2px 4px 0 rgba(0, 0, 0, 0.08);
88
+
89
+ border-radius: 50%;
86
90
  cursor: pointer;
87
91
 
88
92
  transition: border-color 150ms ease-in-out;
@@ -113,7 +117,6 @@
113
117
  & + #{ $self }__inner #{ $self }__visual-input::after {
114
118
  @include border(accent);
115
119
  @include bg-color(accentAlt);
116
- position: absolute;
117
120
  left: 2px;
118
121
  top: 2px;
119
122
 
@@ -0,0 +1,79 @@
1
+ :root {
2
+ --cobalt-layout-y-spacing: 8px;
3
+ --cobalt-layout-x-spacing: 24px;
4
+ }
5
+
6
+ .cobalt-layout-section {
7
+ @include bg-color(primary);
8
+ padding: var(--cobalt-layout-y-spacing) var(--cobalt-layout-x-spacing);
9
+ }
10
+
11
+ .cobalt-layout-card {
12
+ @include bg-color(primary);
13
+ @include border(base);
14
+ margin: var(--cobalt-layout-y-spacing) var(--cobalt-layout-x-spacing);
15
+
16
+ border-radius: border-radius(lg);
17
+
18
+ .cobalt-layout-card__item {
19
+ margin: 16px;
20
+ }
21
+ }
22
+
23
+ div.cobalt-layout-stack {
24
+ @include bg-color(primary);
25
+ @include border(base);
26
+ margin: var(--cobalt-layout-y-spacing) var(--cobalt-layout-x-spacing);
27
+
28
+ border-radius: border-radius(lg);
29
+
30
+ .cobalt-layout-stack__item {
31
+ @include border-top(base);
32
+ padding: 16px;
33
+ }
34
+
35
+ .cobalt-layout-stack__item:first-of-type {
36
+ border-top: 0;
37
+ }
38
+ }
39
+
40
+ table.cobalt-layout-stack {
41
+ @include border(base);
42
+ border-collapse: separate;
43
+ margin: var(--cobalt-layout-y-spacing) var(--cobalt-layout-x-spacing);
44
+
45
+ border-radius: border-radius(lg);
46
+
47
+ .cobalt-layout-stack__item:first-of-type th,
48
+ tbody:not(thead ~ tbody) .cobalt-layout-stack__item:first-of-type td {
49
+ border-top: 0;
50
+ }
51
+
52
+ .cobalt-layout-stack__item td,
53
+ .cobalt-layout-stack__item th {
54
+ @include border-top(base);
55
+ padding: 16px 0;
56
+ }
57
+
58
+ .cobalt-layout-stack__item th:first-of-type,
59
+ .cobalt-layout-stack__item td:first-of-type {
60
+ padding-left: 16px;
61
+ }
62
+
63
+ .cobalt-layout-stack__item th:last-of-type,
64
+ .cobalt-layout-stack__item td:last-of-type {
65
+ padding-right: 16px;
66
+ }
67
+ }
68
+
69
+ .cobalt-layout-page-title {
70
+ @include c-text-title-lg;
71
+ padding: 32px var(--cobalt-layout-x-spacing) var(--cobalt-layout-y-spacing)
72
+ var(--cobalt-layout-x-spacing);
73
+ }
74
+
75
+ .cobalt-layout-section-title {
76
+ @include c-text-title-md;
77
+ padding: 40px var(--cobalt-layout-x-spacing) var(--cobalt-layout-y-spacing)
78
+ var(--cobalt-layout-x-spacing);
79
+ }
@@ -13,6 +13,7 @@
13
13
  @import "./components/Flag/index";
14
14
  @import "./components/Flash/index";
15
15
  @import "./components/Icon/index";
16
+ @import "./components/Layout/Layout";
16
17
  @import "./components/Note/index";
17
18
  @import "./components/PhotoDropzone/index";
18
19
  @import "./components/Pill/index";
@@ -0,0 +1,10 @@
1
+ import React from "react";
2
+ declare const LayoutCard: {
3
+ ({ children }: {
4
+ children: React.ReactNode;
5
+ }): React.JSX.Element;
6
+ Item: ({ children }: {
7
+ children: React.ReactNode;
8
+ }) => React.JSX.Element;
9
+ };
10
+ export default LayoutCard;
@@ -0,0 +1,5 @@
1
+ import React from "react";
2
+ declare const LayoutPageTitle: ({ children }: {
3
+ children: string;
4
+ }) => React.JSX.Element;
5
+ export default LayoutPageTitle;
@@ -0,0 +1,5 @@
1
+ import React from "react";
2
+ declare const LayoutSection: ({ children }: {
3
+ children: React.ReactNode;
4
+ }) => React.JSX.Element;
5
+ export default LayoutSection;
@@ -0,0 +1,5 @@
1
+ import React from "react";
2
+ declare const LayoutSectionTitle: ({ children }: {
3
+ children: string;
4
+ }) => React.JSX.Element;
5
+ export default LayoutSectionTitle;
@@ -0,0 +1,18 @@
1
+ import React from "react";
2
+ type LayoutStackItemPropsType = {
3
+ children: React.ReactNode;
4
+ isTable: never;
5
+ isHeader: never;
6
+ } | {
7
+ children: React.ReactNode;
8
+ isHeader?: boolean;
9
+ isTable?: boolean;
10
+ };
11
+ declare const LayoutStack: {
12
+ ({ children, isTable, }: {
13
+ children: React.ReactNode;
14
+ isTable?: boolean | undefined;
15
+ }): React.JSX.Element;
16
+ Item: ({ children, isTable }: LayoutStackItemPropsType) => React.JSX.Element;
17
+ };
18
+ export default LayoutStack;