@remvst/design-system 1.2.0 → 2.0.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 (47) hide show
  1. package/CHANGELOG.md +21 -0
  2. package/lib/alignment/alignment.d.ts +4 -13
  3. package/lib/alignment/alignment.js +6 -33
  4. package/lib/animations/animations.js +2 -6
  5. package/lib/balanced-row/balanced-row.js +7 -13
  6. package/lib/balanced-stack/balanced-stack.js +7 -13
  7. package/lib/buttons/buttons.js +5 -12
  8. package/lib/component-with-class-name.d.ts +6 -4
  9. package/lib/component-with-class-name.js +11 -14
  10. package/lib/dialog-layout/dialog-layout.js +16 -29
  11. package/lib/dim/dim.d.ts +1 -4
  12. package/lib/dim/dim.js +3 -12
  13. package/lib/dim/transitioning-dim.js +6 -12
  14. package/lib/flow-list/flow-list.js +7 -13
  15. package/lib/focusable.js +5 -11
  16. package/lib/frame/frame.js +3 -7
  17. package/lib/gauge/gauge.js +6 -14
  18. package/lib/highlightable-row/highlightable-row.d.ts +0 -1
  19. package/lib/highlightable-row/highlightable-row.js +3 -7
  20. package/lib/index.js +24 -40
  21. package/lib/key-value-layout/key-value-layout.d.ts +1 -4
  22. package/lib/key-value-layout/key-value-layout.js +3 -12
  23. package/lib/labels/labels.d.ts +7 -22
  24. package/lib/labels/labels.js +9 -54
  25. package/lib/screen-column-layout/screen-column-layout.d.ts +6 -19
  26. package/lib/screen-column-layout/screen-column-layout.js +8 -47
  27. package/lib/screen-stack-layout/screen-stack-layout.d.ts +4 -13
  28. package/lib/screen-stack-layout/screen-stack-layout.js +6 -33
  29. package/lib/scrollable-content/scrollable-content.d.ts +1 -4
  30. package/lib/scrollable-content/scrollable-content.js +3 -12
  31. package/lib/slider/slider.js +8 -17
  32. package/lib/spacing/spacing.js +2 -6
  33. package/lib/stack-list/stack-list.js +7 -13
  34. package/lib/tabs/tabs.js +7 -14
  35. package/lib/typography/typography.js +2 -6
  36. package/package.json +24 -27
  37. package/src/alignment/alignment.tsx +5 -16
  38. package/src/component-with-class-name.tsx +22 -10
  39. package/src/dim/dim.tsx +2 -4
  40. package/src/key-value-layout/key-value-layout.tsx +2 -4
  41. package/src/labels/labels.tsx +8 -28
  42. package/src/screen-column-layout/screen-column-layout.tsx +17 -24
  43. package/src/screen-stack-layout/screen-stack-layout.tsx +9 -16
  44. package/src/scrollable-content/scrollable-content.tsx +2 -4
  45. package/tsconfig.json +7 -7
  46. package/.github/workflows/check.yaml +0 -22
  47. package/.prettierrc +0 -4
@@ -1,54 +1,9 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.TextBlock = exports.MainTitle = exports.TinyLabel = exports.SmallLabel = exports.MediumLabel = exports.LargeLabel = exports.GiantLabel = void 0;
4
- const component_with_class_name_1 = require("../component-with-class-name");
5
- require("./labels.css");
6
- class GiantLabel extends component_with_class_name_1.ComponentWithClassName {
7
- constructor() {
8
- super(...arguments);
9
- this.className = "label label-giant";
10
- }
11
- }
12
- exports.GiantLabel = GiantLabel;
13
- class LargeLabel extends component_with_class_name_1.ComponentWithClassName {
14
- constructor() {
15
- super(...arguments);
16
- this.className = "label label-large";
17
- }
18
- }
19
- exports.LargeLabel = LargeLabel;
20
- class MediumLabel extends component_with_class_name_1.ComponentWithClassName {
21
- constructor() {
22
- super(...arguments);
23
- this.className = "label label-medium";
24
- }
25
- }
26
- exports.MediumLabel = MediumLabel;
27
- class SmallLabel extends component_with_class_name_1.ComponentWithClassName {
28
- constructor() {
29
- super(...arguments);
30
- this.className = "label label-small";
31
- }
32
- }
33
- exports.SmallLabel = SmallLabel;
34
- class TinyLabel extends component_with_class_name_1.ComponentWithClassName {
35
- constructor() {
36
- super(...arguments);
37
- this.className = "label label-tiny";
38
- }
39
- }
40
- exports.TinyLabel = TinyLabel;
41
- class MainTitle extends component_with_class_name_1.ComponentWithClassName {
42
- constructor() {
43
- super(...arguments);
44
- this.className = "label main-title";
45
- }
46
- }
47
- exports.MainTitle = MainTitle;
48
- class TextBlock extends component_with_class_name_1.ComponentWithClassName {
49
- constructor() {
50
- super(...arguments);
51
- this.className = "text-block";
52
- }
53
- }
54
- exports.TextBlock = TextBlock;
1
+ import { divWithClassName } from "../component-with-class-name";
2
+ import "./labels.css";
3
+ export const GiantLabel = divWithClassName("label label-giant");
4
+ export const LargeLabel = divWithClassName("label label-large");
5
+ export const MediumLabel = divWithClassName("label label-medium");
6
+ export const SmallLabel = divWithClassName("label label-small");
7
+ export const TinyLabel = divWithClassName("label label-tiny");
8
+ export const MainTitle = divWithClassName("label main-title");
9
+ export const TextBlock = divWithClassName("text-block");
@@ -1,20 +1,7 @@
1
- import { ComponentWithClassName } from "../component-with-class-name";
2
1
  import "./screen-column-layout.css";
3
- export declare class ScreenColumnLayout extends ComponentWithClassName {
4
- protected readonly className = "screen-layout-column";
5
- }
6
- export declare class ScreenColumnLayoutMainColumn extends ComponentWithClassName {
7
- protected readonly className = "screen-layout-column-main-column";
8
- }
9
- export declare class ScreenColumnLayoutMainColumnHeader extends ComponentWithClassName {
10
- protected readonly className = "screen-layout-column-main-column-header";
11
- }
12
- export declare class ScreenColumnLayoutMainColumnFooter extends ComponentWithClassName {
13
- protected readonly className = "screen-layout-column-main-column-footer";
14
- }
15
- export declare class ScreenColumnLayoutMainColumnContent extends ComponentWithClassName {
16
- protected readonly className = "screen-layout-column-main-column-content";
17
- }
18
- export declare class ScreenColumnLayoutCentralContent extends ComponentWithClassName {
19
- protected readonly className = "screen-layout-column-central-content";
20
- }
2
+ export declare const ScreenColumnLayout: import("react").ForwardRefExoticComponent<import("react").HTMLAttributes<HTMLDivElement> & import("react").RefAttributes<HTMLDivElement>>;
3
+ export declare const ScreenColumnLayoutMainColumn: import("react").ForwardRefExoticComponent<import("react").HTMLAttributes<HTMLDivElement> & import("react").RefAttributes<HTMLDivElement>>;
4
+ export declare const ScreenColumnLayoutMainColumnHeader: import("react").ForwardRefExoticComponent<import("react").HTMLAttributes<HTMLDivElement> & import("react").RefAttributes<HTMLDivElement>>;
5
+ export declare const ScreenColumnLayoutMainColumnFooter: import("react").ForwardRefExoticComponent<import("react").HTMLAttributes<HTMLDivElement> & import("react").RefAttributes<HTMLDivElement>>;
6
+ export declare const ScreenColumnLayoutMainColumnContent: import("react").ForwardRefExoticComponent<import("react").HTMLAttributes<HTMLDivElement> & import("react").RefAttributes<HTMLDivElement>>;
7
+ export declare const ScreenColumnLayoutCentralContent: import("react").ForwardRefExoticComponent<import("react").HTMLAttributes<HTMLDivElement> & import("react").RefAttributes<HTMLDivElement>>;
@@ -1,47 +1,8 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.ScreenColumnLayoutCentralContent = exports.ScreenColumnLayoutMainColumnContent = exports.ScreenColumnLayoutMainColumnFooter = exports.ScreenColumnLayoutMainColumnHeader = exports.ScreenColumnLayoutMainColumn = exports.ScreenColumnLayout = void 0;
4
- const component_with_class_name_1 = require("../component-with-class-name");
5
- require("./screen-column-layout.css");
6
- class ScreenColumnLayout extends component_with_class_name_1.ComponentWithClassName {
7
- constructor() {
8
- super(...arguments);
9
- this.className = "screen-layout-column";
10
- }
11
- }
12
- exports.ScreenColumnLayout = ScreenColumnLayout;
13
- class ScreenColumnLayoutMainColumn extends component_with_class_name_1.ComponentWithClassName {
14
- constructor() {
15
- super(...arguments);
16
- this.className = "screen-layout-column-main-column";
17
- }
18
- }
19
- exports.ScreenColumnLayoutMainColumn = ScreenColumnLayoutMainColumn;
20
- class ScreenColumnLayoutMainColumnHeader extends component_with_class_name_1.ComponentWithClassName {
21
- constructor() {
22
- super(...arguments);
23
- this.className = "screen-layout-column-main-column-header";
24
- }
25
- }
26
- exports.ScreenColumnLayoutMainColumnHeader = ScreenColumnLayoutMainColumnHeader;
27
- class ScreenColumnLayoutMainColumnFooter extends component_with_class_name_1.ComponentWithClassName {
28
- constructor() {
29
- super(...arguments);
30
- this.className = "screen-layout-column-main-column-footer";
31
- }
32
- }
33
- exports.ScreenColumnLayoutMainColumnFooter = ScreenColumnLayoutMainColumnFooter;
34
- class ScreenColumnLayoutMainColumnContent extends component_with_class_name_1.ComponentWithClassName {
35
- constructor() {
36
- super(...arguments);
37
- this.className = "screen-layout-column-main-column-content";
38
- }
39
- }
40
- exports.ScreenColumnLayoutMainColumnContent = ScreenColumnLayoutMainColumnContent;
41
- class ScreenColumnLayoutCentralContent extends component_with_class_name_1.ComponentWithClassName {
42
- constructor() {
43
- super(...arguments);
44
- this.className = "screen-layout-column-central-content";
45
- }
46
- }
47
- exports.ScreenColumnLayoutCentralContent = ScreenColumnLayoutCentralContent;
1
+ import { divWithClassName } from "../component-with-class-name";
2
+ import "./screen-column-layout.css";
3
+ export const ScreenColumnLayout = divWithClassName("screen-layout-column");
4
+ export const ScreenColumnLayoutMainColumn = divWithClassName("screen-layout-column-main-column");
5
+ export const ScreenColumnLayoutMainColumnHeader = divWithClassName("screen-layout-column-main-column-header");
6
+ export const ScreenColumnLayoutMainColumnFooter = divWithClassName("screen-layout-column-main-column-footer");
7
+ export const ScreenColumnLayoutMainColumnContent = divWithClassName("screen-layout-column-main-column-content");
8
+ export const ScreenColumnLayoutCentralContent = divWithClassName("screen-layout-column-central-content");
@@ -1,14 +1,5 @@
1
- import { ComponentWithClassName } from "../component-with-class-name";
2
1
  import "./screen-stack-layout.css";
3
- export declare class ScreenStackLayout extends ComponentWithClassName {
4
- protected readonly className = "screen-stack-layout";
5
- }
6
- export declare class ScreenStackLayoutTop extends ComponentWithClassName {
7
- protected readonly className = "screen-stack-layout-top";
8
- }
9
- export declare class ScreenStackLayoutContent extends ComponentWithClassName {
10
- protected readonly className = "screen-stack-layout-content";
11
- }
12
- export declare class ScreenStackLayoutBottom extends ComponentWithClassName {
13
- protected readonly className = "screen-stack-layout-bottom";
14
- }
2
+ export declare const ScreenStackLayout: import("react").ForwardRefExoticComponent<import("react").HTMLAttributes<HTMLDivElement> & import("react").RefAttributes<HTMLDivElement>>;
3
+ export declare const ScreenStackLayoutTop: import("react").ForwardRefExoticComponent<import("react").HTMLAttributes<HTMLDivElement> & import("react").RefAttributes<HTMLDivElement>>;
4
+ export declare const ScreenStackLayoutContent: import("react").ForwardRefExoticComponent<import("react").HTMLAttributes<HTMLDivElement> & import("react").RefAttributes<HTMLDivElement>>;
5
+ export declare const ScreenStackLayoutBottom: import("react").ForwardRefExoticComponent<import("react").HTMLAttributes<HTMLDivElement> & import("react").RefAttributes<HTMLDivElement>>;
@@ -1,33 +1,6 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.ScreenStackLayoutBottom = exports.ScreenStackLayoutContent = exports.ScreenStackLayoutTop = exports.ScreenStackLayout = void 0;
4
- const component_with_class_name_1 = require("../component-with-class-name");
5
- require("./screen-stack-layout.css");
6
- class ScreenStackLayout extends component_with_class_name_1.ComponentWithClassName {
7
- constructor() {
8
- super(...arguments);
9
- this.className = "screen-stack-layout";
10
- }
11
- }
12
- exports.ScreenStackLayout = ScreenStackLayout;
13
- class ScreenStackLayoutTop extends component_with_class_name_1.ComponentWithClassName {
14
- constructor() {
15
- super(...arguments);
16
- this.className = "screen-stack-layout-top";
17
- }
18
- }
19
- exports.ScreenStackLayoutTop = ScreenStackLayoutTop;
20
- class ScreenStackLayoutContent extends component_with_class_name_1.ComponentWithClassName {
21
- constructor() {
22
- super(...arguments);
23
- this.className = "screen-stack-layout-content";
24
- }
25
- }
26
- exports.ScreenStackLayoutContent = ScreenStackLayoutContent;
27
- class ScreenStackLayoutBottom extends component_with_class_name_1.ComponentWithClassName {
28
- constructor() {
29
- super(...arguments);
30
- this.className = "screen-stack-layout-bottom";
31
- }
32
- }
33
- exports.ScreenStackLayoutBottom = ScreenStackLayoutBottom;
1
+ import { divWithClassName } from "../component-with-class-name";
2
+ import "./screen-stack-layout.css";
3
+ export const ScreenStackLayout = divWithClassName("screen-stack-layout");
4
+ export const ScreenStackLayoutTop = divWithClassName("screen-stack-layout-top");
5
+ export const ScreenStackLayoutContent = divWithClassName("screen-stack-layout-content");
6
+ export const ScreenStackLayoutBottom = divWithClassName("screen-stack-layout-bottom");
@@ -1,5 +1,2 @@
1
- import { ComponentWithClassName } from "../component-with-class-name";
2
1
  import "./scrollable-content.css";
3
- export declare class ScrollableContent extends ComponentWithClassName {
4
- protected readonly className = "scrollable-content";
5
- }
2
+ export declare const ScrollableContent: import("react").ForwardRefExoticComponent<import("react").HTMLAttributes<HTMLDivElement> & import("react").RefAttributes<HTMLDivElement>>;
@@ -1,12 +1,3 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.ScrollableContent = void 0;
4
- const component_with_class_name_1 = require("../component-with-class-name");
5
- require("./scrollable-content.css");
6
- class ScrollableContent extends component_with_class_name_1.ComponentWithClassName {
7
- constructor() {
8
- super(...arguments);
9
- this.className = "scrollable-content";
10
- }
11
- }
12
- exports.ScrollableContent = ScrollableContent;
1
+ import { divWithClassName } from "../component-with-class-name";
2
+ import "./scrollable-content.css";
3
+ export const ScrollableContent = divWithClassName("scrollable-content");
@@ -1,19 +1,13 @@
1
- "use strict";
2
- var __importDefault = (this && this.__importDefault) || function (mod) {
3
- return (mod && mod.__esModule) ? mod : { "default": mod };
4
- };
5
- Object.defineProperty(exports, "__esModule", { value: true });
6
- exports.LabelledSlider = void 0;
7
- const react_1 = __importDefault(require("react"));
8
- const labels_1 = require("../labels/labels");
9
- require("./slider.css");
10
- class Slider extends react_1.default.Component {
1
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
+ import React from "react";
3
+ import { TinyLabel } from "../labels/labels";
4
+ import "./slider.css";
5
+ export default class Slider extends React.Component {
11
6
  render() {
12
- return react_1.default.createElement("input", { type: "range", ...this.props });
7
+ return _jsx("input", { type: "range", ...this.props });
13
8
  }
14
9
  }
15
- exports.default = Slider;
16
- class LabelledSlider extends react_1.default.Component {
10
+ export class LabelledSlider extends React.Component {
17
11
  constructor(props) {
18
12
  super(props);
19
13
  this.state = {
@@ -39,9 +33,6 @@ class LabelledSlider extends react_1.default.Component {
39
33
  }
40
34
  },
41
35
  };
42
- return (react_1.default.createElement("div", { className: "labelled-slider" },
43
- react_1.default.createElement(Slider, { ...sliderProps }),
44
- react_1.default.createElement(labels_1.TinyLabel, null, this.props.label ? this.props.label(this.state.value) : "")));
36
+ return (_jsxs("div", { className: "labelled-slider", children: [_jsx(Slider, { ...sliderProps }), _jsx(TinyLabel, { children: this.props.label ? this.props.label(this.state.value) : "" })] }));
45
37
  }
46
38
  }
47
- exports.LabelledSlider = LabelledSlider;
@@ -1,10 +1,6 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.Spacing = void 0;
4
- require("./spacing.css");
5
- class Spacing {
1
+ import "./spacing.css";
2
+ export class Spacing {
6
3
  }
7
- exports.Spacing = Spacing;
8
4
  Spacing.xxl = "var(--spacing-xxl)";
9
5
  Spacing.xl = "var(--spacing-xl)";
10
6
  Spacing.l = "var(--spacing-l)";
@@ -1,16 +1,10 @@
1
- "use strict";
2
- var __importDefault = (this && this.__importDefault) || function (mod) {
3
- return (mod && mod.__esModule) ? mod : { "default": mod };
4
- };
5
- Object.defineProperty(exports, "__esModule", { value: true });
6
- exports.StackList = void 0;
7
- const react_1 = __importDefault(require("react"));
8
- require("./stack-list.css");
9
- class StackList extends react_1.default.Component {
1
+ import { jsx as _jsx } from "react/jsx-runtime";
2
+ import React from "react";
3
+ import "./stack-list.css";
4
+ export class StackList extends React.Component {
10
5
  render() {
11
- return (react_1.default.createElement("div", { className: "stack-list", ...this.props }, react_1.default.Children.map(this.props.children, (child, i) => {
12
- return react_1.default.createElement("div", { key: `child-${i}` }, child);
13
- })));
6
+ return (_jsx("div", { className: "stack-list", ...this.props, children: React.Children.map(this.props.children, (child, i) => {
7
+ return _jsx("div", { children: child }, `child-${i}`);
8
+ }) }));
14
9
  }
15
10
  }
16
- exports.StackList = StackList;
package/lib/tabs/tabs.js CHANGED
@@ -1,19 +1,13 @@
1
- "use strict";
2
- var __importDefault = (this && this.__importDefault) || function (mod) {
3
- return (mod && mod.__esModule) ? mod : { "default": mod };
4
- };
5
- Object.defineProperty(exports, "__esModule", { value: true });
6
- exports.Tab = exports.TabLayout = void 0;
7
- const react_1 = __importDefault(require("react"));
8
- const focusable_1 = require("../focusable");
9
- require("./tabs.css");
10
- class TabLayout extends react_1.default.Component {
1
+ import { jsx as _jsx } from "react/jsx-runtime";
2
+ import React from "react";
3
+ import { Focusable } from "../focusable";
4
+ import "./tabs.css";
5
+ export class TabLayout extends React.Component {
11
6
  render() {
12
- return (react_1.default.createElement("div", { className: "tab-layout", ...this.props }, this.props.children));
7
+ return (_jsx("div", { className: "tab-layout", ...this.props, children: this.props.children }));
13
8
  }
14
9
  }
15
- exports.TabLayout = TabLayout;
16
- class Tab extends focusable_1.Focusable {
10
+ export class Tab extends Focusable {
17
11
  get className() {
18
12
  let className = "tab";
19
13
  if (this.props.selected) {
@@ -22,4 +16,3 @@ class Tab extends focusable_1.Focusable {
22
16
  return className;
23
17
  }
24
18
  }
25
- exports.Tab = Tab;
@@ -1,10 +1,6 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.Typography = void 0;
4
- require("./typography.css");
5
- class Typography {
1
+ import "./typography.css";
2
+ export class Typography {
6
3
  }
7
- exports.Typography = Typography;
8
4
  Typography.xxl = "var(--font-size-xxl)";
9
5
  Typography.xl = "var(--font-size-xl)";
10
6
  Typography.l = "var(--font-size-l)";
package/package.json CHANGED
@@ -1,28 +1,25 @@
1
1
  {
2
- "name": "@remvst/design-system",
3
- "version": "1.2.0",
4
- "description": "",
5
- "main": "lib/index.js",
6
- "scripts": {
7
- "prettier:fix": "prettier . --write",
8
- "prettier:check": "prettier . --check",
9
- "copy-files": "copyfiles -u 1 src/**/*.css lib/",
10
- "build": "rm -rf lib && tsc && npm run copy-files",
11
- "prepublishOnly": "npm i && npm run build",
12
- "test": "npm run prettier:check && npm run build"
13
- },
14
- "keywords": [],
15
- "author": "Rémi Vansteelandt",
16
- "license": "",
17
- "dependencies": {
18
- "@types/react": "^18.2.45",
19
- "react": "^18.2.0",
20
- "typescript": "^5.2.2"
21
- },
22
- "devDependencies": {
23
- "copyfiles": "^2.4.1",
24
- "prettier": "3.1.1",
25
- "prettier-plugin-organize-imports": "^3.2.4",
26
- "rimraf": "^5.0.5"
27
- }
28
- }
2
+ "name": "@remvst/design-system",
3
+ "version": "2.0.0",
4
+ "description": "",
5
+ "main": "lib/index.js",
6
+ "keywords": [],
7
+ "author": "Rémi Vansteelandt",
8
+ "license": "",
9
+ "peerDependencies": {
10
+ "@types/react": "^19.2.0",
11
+ "react": "^19.2.0"
12
+ },
13
+ "devDependencies": {
14
+ "@types/react": "^19.2.0",
15
+ "copyfiles": "^2.4.1",
16
+ "react": "^19.2.0",
17
+ "rimraf": "^5.0.5",
18
+ "typescript": "^7.0.2"
19
+ },
20
+ "scripts": {
21
+ "copy-files": "copyfiles -u 1 src/**/*.css lib/",
22
+ "build": "rm -rf lib && tsc && npm run copy-files",
23
+ "test": "npm run build"
24
+ }
25
+ }
@@ -1,18 +1,7 @@
1
- import { ComponentWithClassName } from "../component-with-class-name";
1
+ import { divWithClassName } from "../component-with-class-name";
2
2
  import "./alignment.css";
3
3
 
4
- export class VerticalCenter extends ComponentWithClassName {
5
- protected readonly className = "vertical-center";
6
- }
7
-
8
- export class HorizontalCenter extends ComponentWithClassName {
9
- protected readonly className = "horizontal-center";
10
- }
11
-
12
- export class AlignRight extends ComponentWithClassName {
13
- protected readonly className = "align-right";
14
- }
15
-
16
- export class NarrowColumn extends ComponentWithClassName {
17
- protected readonly className = "narrow-column";
18
- }
4
+ export const VerticalCenter = divWithClassName("vertical-center");
5
+ export const HorizontalCenter = divWithClassName("horizontal-center");
6
+ export const AlignRight = divWithClassName("align-right");
7
+ export const NarrowColumn = divWithClassName("narrow-column");
@@ -1,15 +1,27 @@
1
1
  import React from "react";
2
2
 
3
- export abstract class ComponentWithClassName<
3
+ /**
4
+ * Creates a `<div>` component with a fixed base class name. Any `className`
5
+ * passed by the consumer is appended, and all other div props (including
6
+ * `ref`) are forwarded.
7
+ */
8
+ export function divWithClassName<
4
9
  Props extends
5
10
  React.HTMLAttributes<HTMLDivElement> = React.HTMLAttributes<HTMLDivElement>,
6
- > extends React.Component<Props> {
7
- protected abstract readonly className: string;
8
-
9
- render() {
10
- const props = { ...this.props } as any;
11
- props.className = this.className + " " + (this.props.className || "");
12
-
13
- return <div {...props}>{this.props.children}</div>;
14
- }
11
+ >(baseClassName: string) {
12
+ const Component = React.forwardRef<HTMLDivElement, Props>(
13
+ ({ className, children, ...rest }, ref) => (
14
+ <div
15
+ ref={ref}
16
+ className={
17
+ className ? `${baseClassName} ${className}` : baseClassName
18
+ }
19
+ {...rest}
20
+ >
21
+ {children}
22
+ </div>
23
+ ),
24
+ );
25
+ Component.displayName = baseClassName;
26
+ return Component;
15
27
  }
package/src/dim/dim.tsx CHANGED
@@ -1,6 +1,4 @@
1
- import { ComponentWithClassName } from "../component-with-class-name";
1
+ import { divWithClassName } from "../component-with-class-name";
2
2
  import "./dim.css";
3
3
 
4
- export class Dim extends ComponentWithClassName {
5
- protected className = "dim";
6
- }
4
+ export const Dim = divWithClassName("dim");
@@ -1,6 +1,4 @@
1
- import { ComponentWithClassName } from "../component-with-class-name";
1
+ import { divWithClassName } from "../component-with-class-name";
2
2
  import "./key-value-layout.css";
3
3
 
4
- export class KeyValueLayout extends ComponentWithClassName {
5
- protected readonly className = "key-value-layout";
6
- }
4
+ export const KeyValueLayout = divWithClassName("key-value-layout");
@@ -1,30 +1,10 @@
1
- import { ComponentWithClassName } from "../component-with-class-name";
1
+ import { divWithClassName } from "../component-with-class-name";
2
2
  import "./labels.css";
3
3
 
4
- export class GiantLabel extends ComponentWithClassName {
5
- readonly className = "label label-giant";
6
- }
7
-
8
- export class LargeLabel extends ComponentWithClassName {
9
- readonly className = "label label-large";
10
- }
11
-
12
- export class MediumLabel extends ComponentWithClassName {
13
- readonly className = "label label-medium";
14
- }
15
-
16
- export class SmallLabel extends ComponentWithClassName {
17
- readonly className = "label label-small";
18
- }
19
-
20
- export class TinyLabel extends ComponentWithClassName {
21
- readonly className = "label label-tiny";
22
- }
23
-
24
- export class MainTitle extends ComponentWithClassName {
25
- readonly className = "label main-title";
26
- }
27
-
28
- export class TextBlock extends ComponentWithClassName {
29
- readonly className = "text-block";
30
- }
4
+ export const GiantLabel = divWithClassName("label label-giant");
5
+ export const LargeLabel = divWithClassName("label label-large");
6
+ export const MediumLabel = divWithClassName("label label-medium");
7
+ export const SmallLabel = divWithClassName("label label-small");
8
+ export const TinyLabel = divWithClassName("label label-tiny");
9
+ export const MainTitle = divWithClassName("label main-title");
10
+ export const TextBlock = divWithClassName("text-block");
@@ -1,26 +1,19 @@
1
- import { ComponentWithClassName } from "../component-with-class-name";
1
+ import { divWithClassName } from "../component-with-class-name";
2
2
  import "./screen-column-layout.css";
3
3
 
4
- export class ScreenColumnLayout extends ComponentWithClassName {
5
- protected readonly className = "screen-layout-column";
6
- }
7
-
8
- export class ScreenColumnLayoutMainColumn extends ComponentWithClassName {
9
- protected readonly className = "screen-layout-column-main-column";
10
- }
11
-
12
- export class ScreenColumnLayoutMainColumnHeader extends ComponentWithClassName {
13
- protected readonly className = "screen-layout-column-main-column-header";
14
- }
15
-
16
- export class ScreenColumnLayoutMainColumnFooter extends ComponentWithClassName {
17
- protected readonly className = "screen-layout-column-main-column-footer";
18
- }
19
-
20
- export class ScreenColumnLayoutMainColumnContent extends ComponentWithClassName {
21
- protected readonly className = "screen-layout-column-main-column-content";
22
- }
23
-
24
- export class ScreenColumnLayoutCentralContent extends ComponentWithClassName {
25
- protected readonly className = "screen-layout-column-central-content";
26
- }
4
+ export const ScreenColumnLayout = divWithClassName("screen-layout-column");
5
+ export const ScreenColumnLayoutMainColumn = divWithClassName(
6
+ "screen-layout-column-main-column",
7
+ );
8
+ export const ScreenColumnLayoutMainColumnHeader = divWithClassName(
9
+ "screen-layout-column-main-column-header",
10
+ );
11
+ export const ScreenColumnLayoutMainColumnFooter = divWithClassName(
12
+ "screen-layout-column-main-column-footer",
13
+ );
14
+ export const ScreenColumnLayoutMainColumnContent = divWithClassName(
15
+ "screen-layout-column-main-column-content",
16
+ );
17
+ export const ScreenColumnLayoutCentralContent = divWithClassName(
18
+ "screen-layout-column-central-content",
19
+ );
@@ -1,18 +1,11 @@
1
- import { ComponentWithClassName } from "../component-with-class-name";
1
+ import { divWithClassName } from "../component-with-class-name";
2
2
  import "./screen-stack-layout.css";
3
3
 
4
- export class ScreenStackLayout extends ComponentWithClassName {
5
- protected readonly className = "screen-stack-layout";
6
- }
7
-
8
- export class ScreenStackLayoutTop extends ComponentWithClassName {
9
- protected readonly className = "screen-stack-layout-top";
10
- }
11
-
12
- export class ScreenStackLayoutContent extends ComponentWithClassName {
13
- protected readonly className = "screen-stack-layout-content";
14
- }
15
-
16
- export class ScreenStackLayoutBottom extends ComponentWithClassName {
17
- protected readonly className = "screen-stack-layout-bottom";
18
- }
4
+ export const ScreenStackLayout = divWithClassName("screen-stack-layout");
5
+ export const ScreenStackLayoutTop = divWithClassName("screen-stack-layout-top");
6
+ export const ScreenStackLayoutContent = divWithClassName(
7
+ "screen-stack-layout-content",
8
+ );
9
+ export const ScreenStackLayoutBottom = divWithClassName(
10
+ "screen-stack-layout-bottom",
11
+ );
@@ -1,6 +1,4 @@
1
- import { ComponentWithClassName } from "../component-with-class-name";
1
+ import { divWithClassName } from "../component-with-class-name";
2
2
  import "./scrollable-content.css";
3
3
 
4
- export class ScrollableContent extends ComponentWithClassName {
5
- protected readonly className = "scrollable-content";
6
- }
4
+ export const ScrollableContent = divWithClassName("scrollable-content");