@ndwnu/design-system 12.0.0 → 12.2.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,17 +3,19 @@ import { type Meta, type StoryObj } from '@storybook/angular';
3
3
  interface StoryArgs {
4
4
  columnClasses: string[][];
5
5
  disablePadding?: boolean;
6
+ useContainerQueries?: boolean;
6
7
  }
7
8
 
8
9
  /**
9
- * Create a responsive grid layout with columns. There are multiple breakpoints:
10
+ * Create a responsive grid layout with columns. There are multiple breakpoints based
11
+ * on the viewport size. Each breakpoint has a specific number of columns:
10
12
  * - Above 1024px (sm): 12 columns
11
13
  * - 768px-1024px (xs): 6 columns
12
14
  * - 480px-768px (2xs): 4 columns
13
15
  * - Below 480px: 2 columns
14
16
  * - Maximum width: 1440px
15
17
  *
16
- * The grid needs a container element with the class `grid`. Column elements
18
+ * The grid needs a container element with the class `ndw-grid`. Column elements
17
19
  * should have classes like:
18
20
  * - `column-{span}`: all screen sizes
19
21
  * - `column-2xs-{span}`: below 480px
@@ -26,8 +28,22 @@ interface StoryArgs {
26
28
  * Use the viewport tool to see responsive behavior.
27
29
  *
28
30
  * ## Disable padding
31
+ *
29
32
  * Sometimes you may want to disable padding on the columns, for example when using a card component.
30
33
  * To do this, add the class `ndw-grid--no-padding` to the `.ndw-grid` element.
34
+ *
35
+ * ## Container grid
36
+ *
37
+ * It is also possible to use a container grid which uses breakpoints
38
+ * based on it's container instead of the viewport.
39
+ *
40
+ * There are a few notable differences when using a container grid:
41
+ * - Container queries are used instead of media queries.
42
+ * - The container element must have the `ndw-c-grid` class instead of `ndw-grid`.
43
+ * - The column classes are prefixed with `ndw-c-col-` instead of `column-`
44
+ * - The container grid always has 12 columns, regardless of the container size.
45
+ * - The container grid does not have padding on the outside of between columns.
46
+ * - The container grid uses flex layout instead of CSS grid.
31
47
  */
32
48
 
33
49
  const meta: Meta<StoryArgs> = {
@@ -42,22 +58,26 @@ const meta: Meta<StoryArgs> = {
42
58
  props,
43
59
  styles: [
44
60
  `
45
- .ndw-grid > div {
61
+ .ndw-grid > div,
62
+ .ndw-c-grid > div {
63
+ text-align: center;
46
64
  background-color: var(--ndw-color-grey-300);
65
+ border: 1px solid var(--ndw-color-grey-400);
47
66
  padding: var(--ndw-spacing-xs);
48
67
  }
49
- .ndw-grid {
68
+ .ndw-grid,
69
+ .ndw-c-grid {
50
70
  background-color: var(--ndw-color-grey-100);
51
71
  margin-bottom: var(--ndw-spacing-xl);
52
72
  }
53
73
  `,
54
74
  ],
55
75
  template: `
56
- <div class="ndw-grid ${props.disablePadding ? 'ndw-grid--no-padding' : ''}">
76
+ <div class="${props.useContainerQueries ? 'ndw-c-grid' : 'ndw-grid'} ${props.disablePadding ? 'ndw-grid--no-padding' : ''}">
57
77
  ${props.columnClasses
58
78
  .map(
59
79
  (classes, index) =>
60
- `<div class="${classes.join(' ')}">
80
+ `<div class="${classes.map((c) => `${props.useContainerQueries ? 'ndw-c-col-' : 'column-'}${c}`).join(' ')}">
61
81
  ${index + 1}
62
82
  </div>`,
63
83
  )
@@ -66,11 +86,23 @@ const meta: Meta<StoryArgs> = {
66
86
  `,
67
87
  }),
68
88
  argTypes: {
89
+ disablePadding: {
90
+ description: 'Disable the inline padding on the grid.',
91
+ control: { type: 'boolean' },
92
+ table: { category: 'Grid configuration' },
93
+ },
69
94
  columnClasses: {
70
95
  description: 'Array of classes to apply to each column.',
96
+ table: {
97
+ category: 'Story inputs',
98
+ },
71
99
  },
72
- disablePadding: {
73
- description: 'Disable the inline padding on the grid.',
100
+ useContainerQueries: {
101
+ description: 'Use container queries instead of media queries for the grid.',
102
+ control: { type: 'boolean' },
103
+ table: {
104
+ category: 'Story inputs',
105
+ },
74
106
  },
75
107
  },
76
108
  };
@@ -80,19 +112,21 @@ type Story = StoryObj<StoryArgs>;
80
112
  export const Default: Story = {
81
113
  args: {
82
114
  columnClasses: [
83
- ['column-2xs-1', 'column-xs-1', 'column-sm-1', 'column-md-1'],
84
- ['column-2xs-1', 'column-xs-1', 'column-sm-1', 'column-md-1'],
85
- ['column-xs-1', 'column-sm-1', 'column-md-1'],
86
- ['column-xs-1', 'column-sm-1', 'column-md-1'],
87
- ['column-sm-1', 'column-md-1'],
88
- ['column-sm-1', 'column-md-1'],
89
- ['column-md-1'],
90
- ['column-md-1'],
91
- ['column-md-1'],
92
- ['column-md-1'],
93
- ['column-md-1'],
94
- ['column-md-1'],
115
+ ['1', '2xs-4', 'xs-2', 'sm-1'],
116
+ ['1', '2xs-4', 'xs-2', 'sm-1'],
117
+ ['1', 'xs-2', 'sm-1'],
118
+ ['1', 'xs-2', 'sm-1'],
119
+ ['1', 'sm-1'],
120
+ ['1', 'sm-1'],
121
+ ['1'],
122
+ ['1'],
123
+ ['1'],
124
+ ['1'],
125
+ ['1'],
126
+ ['1'],
95
127
  ],
128
+ disablePadding: false,
129
+ useContainerQueries: false,
96
130
  },
97
131
  };
98
132
 
@@ -102,38 +136,33 @@ export const Default: Story = {
102
136
  export const ResponsiveColumns: Story = {
103
137
  args: {
104
138
  columnClasses: [
105
- ['column-12', 'column-md-4', 'column-sm-3'],
106
- ['column-12', 'column-md-4', 'column-sm-3'],
107
- ['column-12', 'column-md-4', 'column-sm-6'],
139
+ ['12', 'sm-3', 'md-4'],
140
+ ['12', 'sm-3', 'md-4'],
141
+ ['12', 'sm-6', 'md-4'],
108
142
  ],
109
143
  },
110
144
  };
111
145
 
112
146
  export const MixedColumnWidth: Story = {
113
147
  args: {
114
- columnClasses: [
115
- ['column-6'],
116
- ['column-2'],
117
- ['column-4'],
118
- ['column-2'],
119
- ['column-2'],
120
- ['column-2'],
121
- ['column-6'],
122
- ['column-12'],
123
- ],
148
+ columnClasses: [['6'], ['2'], ['4'], ['2'], ['2'], ['2'], ['6'], ['12']],
124
149
  },
125
150
  };
126
151
 
127
152
  export const NoPadding: Story = {
128
153
  args: {
154
+ columnClasses: [['6'], ['6'], ['2'], ['2'], ['2'], ['6']],
155
+ disablePadding: true,
156
+ },
157
+ };
158
+
159
+ export const ContainerQueryGrid: Story = {
160
+ args: {
161
+ useContainerQueries: true,
129
162
  columnClasses: [
130
- ['column-6'],
131
- ['column-6'],
132
- ['column-2'],
133
- ['column-2'],
134
- ['column-2'],
135
- ['column-6'],
163
+ ['12', 'sm-6', 'md-4'],
164
+ ['12', 'sm-6', 'md-4'],
165
+ ['12', 'sm-12', 'md-4'],
136
166
  ],
137
- disablePadding: true,
138
167
  },
139
168
  };