@muraldevkit/ui-toolkit 1.8.0 → 1.9.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.
@@ -0,0 +1,44 @@
1
+ /// <reference types="react" />
2
+ import { AttrsObject } from '../../utils';
3
+ import { Kind, Orientation, Spacing } from './constants';
4
+ interface MrlDividerProps {
5
+ /**
6
+ * Applies additional HTML attributes to the divider element.
7
+ */
8
+ attrs?: AttrsObject;
9
+ /**
10
+ * Defines which color scheme to used based on the background color of the container.
11
+ * White/light backgrounds should use "default" and dark/saturated color backgrounds
12
+ * should use "inverse".
13
+ */
14
+ kind: Kind;
15
+ /**
16
+ * Use to set a width/height of a divider to create an offset from surrounding content.
17
+ * This is commonly found in toolbars. Value can be any valid CSS `width/height` value, such as
18
+ * a CSS variable or rem value. Warning, vertical dividers may not work if set to a percentage,
19
+ * due to browser limitations with calculating dynamic heights. You should not set the parent to
20
+ * a static height to make this work as that poses accessibility issues.
21
+ */
22
+ length?: string;
23
+ /**
24
+ * Determines the orientation of the divider based on the sibling elements' orientation.
25
+ * Stacked elements should use "horizontal" and elements displayed in a row should use
26
+ * "vertical". Note for the "vertical" orientation, only usage between a row of Icon Buttons
27
+ * is currently supported.
28
+ */
29
+ orientation: Orientation;
30
+ /**
31
+ * Determines how much space to provide between the elements that the divider is separating.
32
+ * This option only applies to horizontal orientation.
33
+ */
34
+ spacing?: Spacing;
35
+ }
36
+ /**
37
+ * Used to visually and semantically separate two elements.
38
+ * For visual separation only view this package's mixins
39
+ *
40
+ * @param props - component props
41
+ * @returns a MrlDivider React component.
42
+ */
43
+ export declare function MrlDivider({ attrs, kind, length, orientation, spacing }: MrlDividerProps): JSX.Element;
44
+ export {};
@@ -0,0 +1,18 @@
1
+ export declare const allowedValues: {
2
+ kinds: readonly ["default", "inverse"];
3
+ orientations: readonly ["horizontal", "vertical"];
4
+ spacings: readonly ["small", "medium", "large"];
5
+ };
6
+ export type Kind = (typeof allowedValues.kinds)[number];
7
+ export type Orientation = (typeof allowedValues.orientations)[number];
8
+ export type Spacing = (typeof allowedValues.spacings)[number];
9
+ export interface DividerDefaults {
10
+ kind: Kind;
11
+ orientation: Orientation;
12
+ spacing: Spacing;
13
+ }
14
+ /**
15
+ * Default values for props on the Divider component;
16
+ * Shared between the component and Storybook
17
+ */
18
+ export declare const defaults: DividerDefaults;
@@ -0,0 +1,73 @@
1
+ ////
2
+ /// Divider component mixins
3
+ /// @group divider
4
+ ////
5
+
6
+ /// Used to apply a separation between two elements without adding an additional element to the DOM. This is
7
+ /// typically used for things like menus where we don't want to add the DOM elements for accessibility considerations
8
+ /// for screen reader users.
9
+ /// @group mixins
10
+ /// @param {String} $orientation - Defines the orientation of the divider. Available options are: "horizontal" (default)
11
+ /// @param {String} $max-width - Use when the divider should not span the full-width of the container, for example
12
+ /// dividers between stacked Icon Buttons in a toolbar. Set to any valid CSS width value.
13
+ ///
14
+ /// @example @include mrl-divider; // Generates the default horizontal divider that spans the full width of the container
15
+ /// @example @include mrl-divider($max-width: 2rem); // Generates a separation that is only 2rems wide and centers it between
16
+ /// the overall container's width
17
+ /// @todo - since this is no longer used in the component implementation, we need to use this in another component (e.g. menu)
18
+ /// or set up Storybook so we can test Sass mixins to ensure this is not breaking
19
+ @mixin mrl-divider($orientation: 'horizontal', $max-width: '') {
20
+ // Note: if you change this CSS before the @todo comment is addressed, you'll need to run the changes in the product to
21
+ // verify nothing breaks
22
+ position: relative;
23
+
24
+ // We use pseudo elements so we can apply this to non-divider elements
25
+ // for better accessibility support
26
+
27
+ // The :before element is used to ensure the proper spacing as margin-top
28
+ // will push content down but margin-bottom does not reflow the content
29
+
30
+ // The :after element is the actual visual divider we display to the user
31
+ // The element that these pseudo elements are applied to is position relative
32
+
33
+ @if $orientation == 'horizontal' {
34
+ &::before {
35
+ content: '';
36
+ display: block;
37
+ height: 0;
38
+ margin-top: calc(var(--mrl-divider-spacing) * 2);
39
+ width: 100%;
40
+ }
41
+
42
+ &::after {
43
+ background-color: var(--mrl-divider-color);
44
+ content: '';
45
+ display: block;
46
+ height: var(--mrl-divider-size);
47
+ position: absolute;
48
+ top: calc(var(--mrl-divider-spacing) * -1);
49
+ width: 100%;
50
+
51
+ /* stylelint-disable-next-line max-nesting-depth */
52
+ @if $max-width != '' {
53
+ @include mrl-divider-center;
54
+
55
+ max-width: $max-width;
56
+ }
57
+ }
58
+ } @else {
59
+ // @todo - the pseudo elements can't push content to the right
60
+ // in order to get the correct spacing
61
+ @warn 'Vertical dividers are not supported as pseudo elements';
62
+ }
63
+ }
64
+
65
+ /// Used to create DRY code for shared styles between the actual divider component and mixin.
66
+ /// This mixin is not intended for external adoption.
67
+ /// @group mixins
68
+ ///
69
+ /// @example @include mrl-divider-center; // Adds shared code to your implementation
70
+ @mixin mrl-divider-center() {
71
+ left: 50%;
72
+ transform: translateX(-50%);
73
+ }
@@ -0,0 +1,35 @@
1
+ ////
2
+ /// Divider component styles
3
+ /// @group divider
4
+ ////
5
+
6
+ @use './styles.variables.scss';
7
+
8
+ // Horizontal divider
9
+ .MrlDivider--horizontal {
10
+ background-color: var(--mrl-divider-color);
11
+ display: block;
12
+ height: var(--mrl-divider-size);
13
+ margin: var(--mrl-divider-spacing) 0;
14
+ width: 100%;
15
+
16
+ .MrlDivider--center {
17
+ margin: var(--mrl-divider-spacing) auto;
18
+ }
19
+ }
20
+
21
+ // Vertical divider
22
+ .MrlDivider--vertical {
23
+ // A display: flex parent will give the most consistent and expected results
24
+ // but we add display: inline-block just in case so the user can at least see
25
+ // the divider and then tweak positioning as needed.
26
+ align-self: stretch;
27
+ background-color: var(--mrl-divider-color);
28
+ display: inline-block;
29
+ margin: 0 var(--mrl-divider-spacing);
30
+ width: var(--mrl-divider-size);
31
+
32
+ .MrlDivider--center {
33
+ align-self: center;
34
+ }
35
+ }
@@ -0,0 +1,30 @@
1
+ ////
2
+ /// Divider component variables
3
+ /// @group divider
4
+ ////
5
+
6
+ // Need to define on both the host and root to support traditional DOM and Shadow DOM
7
+ .MrlDivider {
8
+ --mrl-divider-size: var(--mrl-spacing-01);
9
+ --mrl-divider-spacing: var(--mrl-space-stack-section-divider);
10
+ --mrl-divider-color: var(--mrl-color-line-divider);
11
+ }
12
+
13
+ // Spacing variants (only applies to horizontal dividers)
14
+ .MrlDivider--small {
15
+ --mrl-divider-spacing: var(--mrl-space-stack-section-divider-small);
16
+ }
17
+
18
+ .MrlDivider--large {
19
+ --mrl-divider-spacing: var(--mrl-space-stack-section-divider-large);
20
+ }
21
+
22
+ // Kind variants
23
+ .MrlDivider--inverse {
24
+ --mrl-divider-color: var(--mrl-color-line-divider-inverse);
25
+ }
26
+
27
+ // Orientation variants
28
+ .MrlDivider--vertical {
29
+ --mrl-divider-spacing: var(--mrl-spacing-02);
30
+ }
@@ -21,7 +21,6 @@ export declare const setClasses: (customClasses: AttrsObject | string | undefine
21
21
  * @param {AttrsObject | string} attributes - The custom attributes passed to the component
22
22
  * @param {AttrsObject} [defaults={}] - An optional object of the default attributes of a component
23
23
  * @param {string} className - Default classes to apply to the component
24
- * @param {boolean} forReact - Whether or not the attributes are being set for a React component.
25
24
  *
26
25
  * Use when applying attributes such as a className directly to a react component.
27
26
  * @returns {AttrsObject} - An object of component attributes
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@muraldevkit/ui-toolkit",
3
- "version": "1.8.0",
3
+ "version": "1.9.0",
4
4
  "description": "Mural's UI Toolkit",
5
5
  "main": "./dist/index.js",
6
6
  "module": "./dist/index.js",