@nuralyui/grid 0.0.1
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.
- package/bundle.js +256 -0
- package/col.component.d.ts +103 -0
- package/col.component.js +253 -0
- package/col.component.js.map +1 -0
- package/col.style.d.ts +6 -0
- package/col.style.js +117 -0
- package/col.style.js.map +1 -0
- package/grid.types.d.ts +80 -0
- package/grid.types.js +16 -0
- package/grid.types.js.map +1 -0
- package/index.d.ts +4 -0
- package/index.js +4 -0
- package/index.js.map +1 -0
- package/package.json +52 -0
- package/react.d.ts +5 -0
- package/react.js +17 -0
- package/react.js.map +1 -0
- package/row.component.d.ts +83 -0
- package/row.component.js +197 -0
- package/row.component.js.map +1 -0
- package/row.style.d.ts +6 -0
- package/row.style.js +68 -0
- package/row.style.js.map +1 -0
|
@@ -0,0 +1,83 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @license
|
|
3
|
+
* Copyright 2023 Nuraly, Laabidi Aymen
|
|
4
|
+
* SPDX-License-Identifier: MIT
|
|
5
|
+
*/
|
|
6
|
+
import { LitElement } from 'lit';
|
|
7
|
+
import { RowAlign, RowJustify, Gutter } from './grid.types.js';
|
|
8
|
+
declare const NrRowElement_base: (new (...args: any[]) => import("../../shared/dependency-mixin.js").DependencyAware) & (new (...args: any[]) => import("../../shared/theme-mixin.js").ThemeAware) & (new (...args: any[]) => import("../../shared/event-handler-mixin.js").EventHandlerCapable) & typeof LitElement;
|
|
9
|
+
/**
|
|
10
|
+
* Row component for grid layout system
|
|
11
|
+
*
|
|
12
|
+
* @example
|
|
13
|
+
* ```html
|
|
14
|
+
* <!-- Basic row -->
|
|
15
|
+
* <nr-row>
|
|
16
|
+
* <nr-col span="12">Column 1</nr-col>
|
|
17
|
+
* <nr-col span="12">Column 2</nr-col>
|
|
18
|
+
* </nr-row>
|
|
19
|
+
*
|
|
20
|
+
* <!-- Row with gutter -->
|
|
21
|
+
* <nr-row gutter="16">
|
|
22
|
+
* <nr-col span="8">Column 1</nr-col>
|
|
23
|
+
* <nr-col span="8">Column 2</nr-col>
|
|
24
|
+
* <nr-col span="8">Column 3</nr-col>
|
|
25
|
+
* </nr-row>
|
|
26
|
+
*
|
|
27
|
+
* <!-- Responsive gutter -->
|
|
28
|
+
* <nr-row .gutter=${{ xs: 8, sm: 16, md: 24, lg: 32 }}>
|
|
29
|
+
* <nr-col span="6">Column</nr-col>
|
|
30
|
+
* </nr-row>
|
|
31
|
+
*
|
|
32
|
+
* <!-- Alignment and justify -->
|
|
33
|
+
* <nr-row align="middle" justify="center">
|
|
34
|
+
* <nr-col span="6">Centered</nr-col>
|
|
35
|
+
* </nr-row>
|
|
36
|
+
* ```
|
|
37
|
+
*
|
|
38
|
+
* @slot default - Column elements
|
|
39
|
+
*/
|
|
40
|
+
export declare class NrRowElement extends NrRowElement_base {
|
|
41
|
+
static styles: import("lit").CSSResult;
|
|
42
|
+
/** Vertical alignment of columns */
|
|
43
|
+
align: RowAlign | '';
|
|
44
|
+
/** Horizontal alignment of columns */
|
|
45
|
+
justify: RowJustify | '';
|
|
46
|
+
/** Grid spacing - number, [horizontal, vertical], or responsive object */
|
|
47
|
+
gutter: Gutter;
|
|
48
|
+
/** Allow columns to wrap */
|
|
49
|
+
wrap: boolean;
|
|
50
|
+
/** Current breakpoint for responsive gutter */
|
|
51
|
+
private currentBreakpoint;
|
|
52
|
+
private resizeObserver?;
|
|
53
|
+
connectedCallback(): void;
|
|
54
|
+
disconnectedCallback(): void;
|
|
55
|
+
/**
|
|
56
|
+
* Setup responsive gutter based on viewport width
|
|
57
|
+
*/
|
|
58
|
+
private setupResponsiveGutter;
|
|
59
|
+
/**
|
|
60
|
+
* Update current breakpoint based on window width
|
|
61
|
+
*/
|
|
62
|
+
private updateBreakpoint;
|
|
63
|
+
/**
|
|
64
|
+
* Get the current gutter values [horizontal, vertical]
|
|
65
|
+
*/
|
|
66
|
+
private getGutterValues;
|
|
67
|
+
/**
|
|
68
|
+
* Get inline styles for row with gutter
|
|
69
|
+
*/
|
|
70
|
+
private getRowStyle;
|
|
71
|
+
/**
|
|
72
|
+
* Get gutter context for child columns
|
|
73
|
+
*/
|
|
74
|
+
private getGutterContext;
|
|
75
|
+
render(): import("lit").TemplateResult<1>;
|
|
76
|
+
}
|
|
77
|
+
declare global {
|
|
78
|
+
interface HTMLElementTagNameMap {
|
|
79
|
+
'nr-row': NrRowElement;
|
|
80
|
+
}
|
|
81
|
+
}
|
|
82
|
+
export {};
|
|
83
|
+
//# sourceMappingURL=row.component.d.ts.map
|
package/row.component.js
ADDED
|
@@ -0,0 +1,197 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @license
|
|
3
|
+
* Copyright 2023 Nuraly, Laabidi Aymen
|
|
4
|
+
* SPDX-License-Identifier: MIT
|
|
5
|
+
*/
|
|
6
|
+
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
|
7
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
8
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
9
|
+
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
10
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
11
|
+
};
|
|
12
|
+
import { html, LitElement } from 'lit';
|
|
13
|
+
import { customElement, property, state } from 'lit/decorators.js';
|
|
14
|
+
import { styles } from './row.style.js';
|
|
15
|
+
import { NuralyUIBaseMixin } from '../../shared/base-mixin.js';
|
|
16
|
+
import { EMPTY_STRING, BREAKPOINTS } from './grid.types.js';
|
|
17
|
+
/**
|
|
18
|
+
* Row component for grid layout system
|
|
19
|
+
*
|
|
20
|
+
* @example
|
|
21
|
+
* ```html
|
|
22
|
+
* <!-- Basic row -->
|
|
23
|
+
* <nr-row>
|
|
24
|
+
* <nr-col span="12">Column 1</nr-col>
|
|
25
|
+
* <nr-col span="12">Column 2</nr-col>
|
|
26
|
+
* </nr-row>
|
|
27
|
+
*
|
|
28
|
+
* <!-- Row with gutter -->
|
|
29
|
+
* <nr-row gutter="16">
|
|
30
|
+
* <nr-col span="8">Column 1</nr-col>
|
|
31
|
+
* <nr-col span="8">Column 2</nr-col>
|
|
32
|
+
* <nr-col span="8">Column 3</nr-col>
|
|
33
|
+
* </nr-row>
|
|
34
|
+
*
|
|
35
|
+
* <!-- Responsive gutter -->
|
|
36
|
+
* <nr-row .gutter=${{ xs: 8, sm: 16, md: 24, lg: 32 }}>
|
|
37
|
+
* <nr-col span="6">Column</nr-col>
|
|
38
|
+
* </nr-row>
|
|
39
|
+
*
|
|
40
|
+
* <!-- Alignment and justify -->
|
|
41
|
+
* <nr-row align="middle" justify="center">
|
|
42
|
+
* <nr-col span="6">Centered</nr-col>
|
|
43
|
+
* </nr-row>
|
|
44
|
+
* ```
|
|
45
|
+
*
|
|
46
|
+
* @slot default - Column elements
|
|
47
|
+
*/
|
|
48
|
+
let NrRowElement = class NrRowElement extends NuralyUIBaseMixin(LitElement) {
|
|
49
|
+
constructor() {
|
|
50
|
+
super(...arguments);
|
|
51
|
+
/** Vertical alignment of columns */
|
|
52
|
+
this.align = EMPTY_STRING;
|
|
53
|
+
/** Horizontal alignment of columns */
|
|
54
|
+
this.justify = EMPTY_STRING;
|
|
55
|
+
/** Grid spacing - number, [horizontal, vertical], or responsive object */
|
|
56
|
+
this.gutter = 0;
|
|
57
|
+
/** Allow columns to wrap */
|
|
58
|
+
this.wrap = true;
|
|
59
|
+
/** Current breakpoint for responsive gutter */
|
|
60
|
+
this.currentBreakpoint = "xs" /* GridBreakpoint.XS */;
|
|
61
|
+
}
|
|
62
|
+
connectedCallback() {
|
|
63
|
+
super.connectedCallback();
|
|
64
|
+
this.setupResponsiveGutter();
|
|
65
|
+
}
|
|
66
|
+
disconnectedCallback() {
|
|
67
|
+
var _a;
|
|
68
|
+
super.disconnectedCallback();
|
|
69
|
+
(_a = this.resizeObserver) === null || _a === void 0 ? void 0 : _a.disconnect();
|
|
70
|
+
}
|
|
71
|
+
/**
|
|
72
|
+
* Setup responsive gutter based on viewport width
|
|
73
|
+
*/
|
|
74
|
+
setupResponsiveGutter() {
|
|
75
|
+
if (typeof this.gutter === 'object' && !Array.isArray(this.gutter)) {
|
|
76
|
+
this.updateBreakpoint();
|
|
77
|
+
this.resizeObserver = new ResizeObserver(() => {
|
|
78
|
+
this.updateBreakpoint();
|
|
79
|
+
});
|
|
80
|
+
this.resizeObserver.observe(document.documentElement);
|
|
81
|
+
}
|
|
82
|
+
}
|
|
83
|
+
/**
|
|
84
|
+
* Update current breakpoint based on window width
|
|
85
|
+
*/
|
|
86
|
+
updateBreakpoint() {
|
|
87
|
+
const width = window.innerWidth;
|
|
88
|
+
if (width >= BREAKPOINTS.xxl) {
|
|
89
|
+
this.currentBreakpoint = "xxl" /* GridBreakpoint.XXL */;
|
|
90
|
+
}
|
|
91
|
+
else if (width >= BREAKPOINTS.xl) {
|
|
92
|
+
this.currentBreakpoint = "xl" /* GridBreakpoint.XL */;
|
|
93
|
+
}
|
|
94
|
+
else if (width >= BREAKPOINTS.lg) {
|
|
95
|
+
this.currentBreakpoint = "lg" /* GridBreakpoint.LG */;
|
|
96
|
+
}
|
|
97
|
+
else if (width >= BREAKPOINTS.md) {
|
|
98
|
+
this.currentBreakpoint = "md" /* GridBreakpoint.MD */;
|
|
99
|
+
}
|
|
100
|
+
else if (width >= BREAKPOINTS.sm) {
|
|
101
|
+
this.currentBreakpoint = "sm" /* GridBreakpoint.SM */;
|
|
102
|
+
}
|
|
103
|
+
else {
|
|
104
|
+
this.currentBreakpoint = "xs" /* GridBreakpoint.XS */;
|
|
105
|
+
}
|
|
106
|
+
}
|
|
107
|
+
/**
|
|
108
|
+
* Get the current gutter values [horizontal, vertical]
|
|
109
|
+
*/
|
|
110
|
+
getGutterValues() {
|
|
111
|
+
if (typeof this.gutter === 'number') {
|
|
112
|
+
return [this.gutter, this.gutter];
|
|
113
|
+
}
|
|
114
|
+
if (Array.isArray(this.gutter)) {
|
|
115
|
+
return this.gutter;
|
|
116
|
+
}
|
|
117
|
+
// Responsive gutter object
|
|
118
|
+
const breakpoints = [
|
|
119
|
+
this.currentBreakpoint,
|
|
120
|
+
"xl" /* GridBreakpoint.XL */,
|
|
121
|
+
"lg" /* GridBreakpoint.LG */,
|
|
122
|
+
"md" /* GridBreakpoint.MD */,
|
|
123
|
+
"sm" /* GridBreakpoint.SM */,
|
|
124
|
+
"xs" /* GridBreakpoint.XS */
|
|
125
|
+
];
|
|
126
|
+
for (const bp of breakpoints) {
|
|
127
|
+
const value = this.gutter[bp];
|
|
128
|
+
if (value !== undefined) {
|
|
129
|
+
if (typeof value === 'number') {
|
|
130
|
+
return [value, value];
|
|
131
|
+
}
|
|
132
|
+
return value;
|
|
133
|
+
}
|
|
134
|
+
}
|
|
135
|
+
return [0, 0];
|
|
136
|
+
}
|
|
137
|
+
/**
|
|
138
|
+
* Get inline styles for row with gutter
|
|
139
|
+
*/
|
|
140
|
+
getRowStyle() {
|
|
141
|
+
const [horizontal, vertical] = this.getGutterValues();
|
|
142
|
+
const styles = {};
|
|
143
|
+
if (horizontal > 0) {
|
|
144
|
+
styles['margin-left'] = `-${horizontal / 2}px`;
|
|
145
|
+
styles['margin-right'] = `-${horizontal / 2}px`;
|
|
146
|
+
}
|
|
147
|
+
if (vertical > 0) {
|
|
148
|
+
styles['row-gap'] = `${vertical}px`;
|
|
149
|
+
}
|
|
150
|
+
return styles;
|
|
151
|
+
}
|
|
152
|
+
/**
|
|
153
|
+
* Get gutter context for child columns
|
|
154
|
+
*/
|
|
155
|
+
getGutterContext() {
|
|
156
|
+
const [horizontal] = this.getGutterValues();
|
|
157
|
+
return horizontal;
|
|
158
|
+
}
|
|
159
|
+
render() {
|
|
160
|
+
const rowStyle = this.getRowStyle();
|
|
161
|
+
const gutter = this.getGutterContext();
|
|
162
|
+
return html `
|
|
163
|
+
<div
|
|
164
|
+
class="nr-row"
|
|
165
|
+
data-align="${this.align}"
|
|
166
|
+
data-justify="${this.justify}"
|
|
167
|
+
data-wrap="${this.wrap}"
|
|
168
|
+
data-theme="${this.currentTheme}"
|
|
169
|
+
style="${Object.entries(rowStyle).map(([key, value]) => `${key}: ${value}`).join('; ')}"
|
|
170
|
+
data-gutter="${gutter}"
|
|
171
|
+
>
|
|
172
|
+
<slot></slot>
|
|
173
|
+
</div>
|
|
174
|
+
`;
|
|
175
|
+
}
|
|
176
|
+
};
|
|
177
|
+
NrRowElement.styles = styles;
|
|
178
|
+
__decorate([
|
|
179
|
+
property({ type: String })
|
|
180
|
+
], NrRowElement.prototype, "align", void 0);
|
|
181
|
+
__decorate([
|
|
182
|
+
property({ type: String })
|
|
183
|
+
], NrRowElement.prototype, "justify", void 0);
|
|
184
|
+
__decorate([
|
|
185
|
+
property({ type: Object })
|
|
186
|
+
], NrRowElement.prototype, "gutter", void 0);
|
|
187
|
+
__decorate([
|
|
188
|
+
property({ type: Boolean })
|
|
189
|
+
], NrRowElement.prototype, "wrap", void 0);
|
|
190
|
+
__decorate([
|
|
191
|
+
state()
|
|
192
|
+
], NrRowElement.prototype, "currentBreakpoint", void 0);
|
|
193
|
+
NrRowElement = __decorate([
|
|
194
|
+
customElement('nr-row')
|
|
195
|
+
], NrRowElement);
|
|
196
|
+
export { NrRowElement };
|
|
197
|
+
//# sourceMappingURL=row.component.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"row.component.js","sourceRoot":"","sources":["../../../src/components/grid/row.component.ts"],"names":[],"mappings":"AAAA;;;;GAIG;;;;;;;AAEH,OAAO,EAAE,IAAI,EAAE,UAAU,EAAE,MAAM,KAAK,CAAC;AACvC,OAAO,EAAE,aAAa,EAAE,QAAQ,EAAE,KAAK,EAAE,MAAM,mBAAmB,CAAC;AACnE,OAAO,EAAE,MAAM,EAAE,MAAM,gBAAgB,CAAC;AACxC,OAAO,EAAE,iBA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,EAAE,MAAM,EAAE,CAAC;4CACR;AAInB;IADC,QAAQ,CAAC,EAAE,IAAI,EAAE,OAAO,EAAE,CAAC;0CAChB;AAIZ;IADC,KAAK,EAAE;uDACsD;AArBnD,YAAY;IADxB,aAAa,CAAC,QAAQ,CAAC;GACX,YAAY,CAwJxB;SAxJY,YAAY","sourcesContent":["/**\n * @license\n * Copyright 2023 Nuraly, Laabidi Aymen\n * SPDX-License-Identifier: MIT\n */\n\nimport { html, LitElement } from 'lit';\nimport { customElement, property, state } from 'lit/decorators.js';\nimport { styles } from './row.style.js';\nimport { NuralyUIBaseMixin } from '../../shared/base-mixin.js';\nimport { RowAlign, RowJustify, Gutter, EMPTY_STRING, GridBreakpoint, BREAKPOINTS } from './grid.types.js';\n\n/**\n * Row component for grid layout system\n * \n * @example\n * ```html\n * <!-- Basic row -->\n * <nr-row>\n * <nr-col span=\"12\">Column 1</nr-col>\n * <nr-col span=\"12\">Column 2</nr-col>\n * </nr-row>\n * \n * <!-- Row with gutter -->\n * <nr-row gutter=\"16\">\n * <nr-col span=\"8\">Column 1</nr-col>\n * <nr-col span=\"8\">Column 2</nr-col>\n * <nr-col span=\"8\">Column 3</nr-col>\n * </nr-row>\n * \n * <!-- Responsive gutter -->\n * <nr-row .gutter=${{ xs: 8, sm: 16, md: 24, lg: 32 }}>\n * <nr-col span=\"6\">Column</nr-col>\n * </nr-row>\n * \n * <!-- Alignment and justify -->\n * <nr-row align=\"middle\" justify=\"center\">\n * <nr-col span=\"6\">Centered</nr-col>\n * </nr-row>\n * ```\n * \n * @slot default - Column elements\n */\n@customElement('nr-row')\nexport class NrRowElement extends NuralyUIBaseMixin(LitElement) {\n static override styles = styles;\n\n /** Vertical alignment of columns */\n @property({ type: String })\n align: RowAlign | '' = EMPTY_STRING;\n\n /** Horizontal alignment of columns */\n @property({ type: String })\n justify: RowJustify | '' = EMPTY_STRING;\n\n /** Grid spacing - number, [horizontal, vertical], or responsive object */\n @property({ type: Object })\n gutter: Gutter = 0;\n\n /** Allow columns to wrap */\n @property({ type: Boolean })\n wrap = true;\n\n /** Current breakpoint for responsive gutter */\n @state()\n private currentBreakpoint: GridBreakpoint = GridBreakpoint.XS;\n\n private resizeObserver?: ResizeObserver;\n\n override connectedCallback() {\n super.connectedCallback();\n this.setupResponsiveGutter();\n }\n\n override disconnectedCallback() {\n super.disconnectedCallback();\n this.resizeObserver?.disconnect();\n }\n\n /**\n * Setup responsive gutter based on viewport width\n */\n private setupResponsiveGutter() {\n if (typeof this.gutter === 'object' && !Array.isArray(this.gutter)) {\n this.updateBreakpoint();\n \n this.resizeObserver = new ResizeObserver(() => {\n this.updateBreakpoint();\n });\n \n this.resizeObserver.observe(document.documentElement);\n }\n }\n\n /**\n * Update current breakpoint based on window width\n */\n private updateBreakpoint() {\n const width = window.innerWidth;\n \n if (width >= BREAKPOINTS.xxl) {\n this.currentBreakpoint = GridBreakpoint.XXL;\n } else if (width >= BREAKPOINTS.xl) {\n this.currentBreakpoint = GridBreakpoint.XL;\n } else if (width >= BREAKPOINTS.lg) {\n this.currentBreakpoint = GridBreakpoint.LG;\n } else if (width >= BREAKPOINTS.md) {\n this.currentBreakpoint = GridBreakpoint.MD;\n } else if (width >= BREAKPOINTS.sm) {\n this.currentBreakpoint = GridBreakpoint.SM;\n } else {\n this.currentBreakpoint = GridBreakpoint.XS;\n }\n }\n\n /**\n * Get the current gutter values [horizontal, vertical]\n */\n private getGutterValues(): [number, number] {\n if (typeof this.gutter === 'number') {\n return [this.gutter, this.gutter];\n }\n \n if (Array.isArray(this.gutter)) {\n return this.gutter;\n }\n \n // Responsive gutter object\n const breakpoints: GridBreakpoint[] = [\n this.currentBreakpoint,\n GridBreakpoint.XL,\n GridBreakpoint.LG,\n GridBreakpoint.MD,\n GridBreakpoint.SM,\n GridBreakpoint.XS\n ];\n \n for (const bp of breakpoints) {\n const value = this.gutter[bp];\n if (value !== undefined) {\n if (typeof value === 'number') {\n return [value, value];\n }\n return value;\n }\n }\n \n return [0, 0];\n }\n\n /**\n * Get inline styles for row with gutter\n */\n private getRowStyle() {\n const [horizontal, vertical] = this.getGutterValues();\n \n const styles: Record<string, string> = {};\n \n if (horizontal > 0) {\n styles['margin-left'] = `-${horizontal / 2}px`;\n styles['margin-right'] = `-${horizontal / 2}px`;\n }\n \n if (vertical > 0) {\n styles['row-gap'] = `${vertical}px`;\n }\n \n return styles;\n }\n\n /**\n * Get gutter context for child columns\n */\n private getGutterContext() {\n const [horizontal] = this.getGutterValues();\n return horizontal;\n }\n\n override render() {\n const rowStyle = this.getRowStyle();\n const gutter = this.getGutterContext();\n\n return html`\n <div\n class=\"nr-row\"\n data-align=\"${this.align}\"\n data-justify=\"${this.justify}\"\n data-wrap=\"${this.wrap}\"\n data-theme=\"${this.currentTheme}\"\n style=\"${Object.entries(rowStyle).map(([key, value]) => `${key}: ${value}`).join('; ')}\"\n data-gutter=\"${gutter}\"\n >\n <slot></slot>\n </div>\n `;\n }\n}\n\ndeclare global {\n interface HTMLElementTagNameMap {\n 'nr-row': NrRowElement;\n }\n}\n"]}
|
package/row.style.d.ts
ADDED
package/row.style.js
ADDED
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
import { css } from 'lit';
|
|
2
|
+
/**
|
|
3
|
+
* Row component styles for the Grid system
|
|
4
|
+
* Using shared CSS variables from /src/shared/themes/
|
|
5
|
+
*/
|
|
6
|
+
export const styles = css `
|
|
7
|
+
:host {
|
|
8
|
+
display: block;
|
|
9
|
+
width: 100%;
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
.nr-row {
|
|
13
|
+
display: flex;
|
|
14
|
+
flex-flow: row wrap;
|
|
15
|
+
min-width: 0;
|
|
16
|
+
|
|
17
|
+
/* Theme-aware */
|
|
18
|
+
color: var(--nuraly-color-text);
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
/* Wrap control */
|
|
22
|
+
.nr-row[data-wrap="false"] {
|
|
23
|
+
flex-wrap: nowrap;
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
/* Horizontal alignment (justify-content) */
|
|
27
|
+
.nr-row[data-justify="start"] {
|
|
28
|
+
justify-content: flex-start;
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
.nr-row[data-justify="end"] {
|
|
32
|
+
justify-content: flex-end;
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
.nr-row[data-justify="center"] {
|
|
36
|
+
justify-content: center;
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
.nr-row[data-justify="space-around"] {
|
|
40
|
+
justify-content: space-around;
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
.nr-row[data-justify="space-between"] {
|
|
44
|
+
justify-content: space-between;
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
.nr-row[data-justify="space-evenly"] {
|
|
48
|
+
justify-content: space-evenly;
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
/* Vertical alignment (align-items) */
|
|
52
|
+
.nr-row[data-align="top"] {
|
|
53
|
+
align-items: flex-start;
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
.nr-row[data-align="middle"] {
|
|
57
|
+
align-items: center;
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
.nr-row[data-align="bottom"] {
|
|
61
|
+
align-items: flex-end;
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
.nr-row[data-align="stretch"] {
|
|
65
|
+
align-items: stretch;
|
|
66
|
+
}
|
|
67
|
+
`;
|
|
68
|
+
//# sourceMappingURL=row.style.js.map
|
package/row.style.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"row.style.js","sourceRoot":"","sources":["../../../src/components/grid/row.style.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,GAAG,EAAE,MAAM,KAAK,CAAC;AAE1B;;;GAGG;AACH,MAAM,CAAC,MAAM,MAAM,GAAG,GAAG,CAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CA6DxB,CAAC","sourcesContent":["import { css } from 'lit';\n\n/**\n * Row component styles for the Grid system\n * Using shared CSS variables from /src/shared/themes/\n */\nexport const styles = css`\n :host {\n display: block;\n width: 100%;\n }\n\n .nr-row {\n display: flex;\n flex-flow: row wrap;\n min-width: 0;\n \n /* Theme-aware */\n color: var(--nuraly-color-text);\n }\n\n /* Wrap control */\n .nr-row[data-wrap=\"false\"] {\n flex-wrap: nowrap;\n }\n\n /* Horizontal alignment (justify-content) */\n .nr-row[data-justify=\"start\"] {\n justify-content: flex-start;\n }\n\n .nr-row[data-justify=\"end\"] {\n justify-content: flex-end;\n }\n\n .nr-row[data-justify=\"center\"] {\n justify-content: center;\n }\n\n .nr-row[data-justify=\"space-around\"] {\n justify-content: space-around;\n }\n\n .nr-row[data-justify=\"space-between\"] {\n justify-content: space-between;\n }\n\n .nr-row[data-justify=\"space-evenly\"] {\n justify-content: space-evenly;\n }\n\n /* Vertical alignment (align-items) */\n .nr-row[data-align=\"top\"] {\n align-items: flex-start;\n }\n\n .nr-row[data-align=\"middle\"] {\n align-items: center;\n }\n\n .nr-row[data-align=\"bottom\"] {\n align-items: flex-end;\n }\n\n .nr-row[data-align=\"stretch\"] {\n align-items: stretch;\n }\n`;\n"]}
|