@weni/unnnic-system 3.9.1-alpha.2 → 3.9.1-alpha.3

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@weni/unnnic-system",
3
- "version": "3.9.1-alpha.2",
3
+ "version": "3.9.1-alpha.3",
4
4
  "type": "commonjs",
5
5
  "files": [
6
6
  "dist",
@@ -0,0 +1,154 @@
1
+ <template>
2
+ <header
3
+ :class="`page-header
4
+ ${hasBackButton ? 'page-header--has-back-button' : ''}
5
+ ${hasTabsSlot ? 'page-header--has-tabs' : ''}
6
+ `"
7
+ >
8
+ <UnnnicButton
9
+ v-if="hasBackButton"
10
+ data-testid="back-button"
11
+ type="tertiary"
12
+ iconCenter="arrow_back_ios_new"
13
+ class="page-header__back-button"
14
+ @click="handleBackClick"
15
+ />
16
+
17
+ <section class="page-header__infos">
18
+ <section class="page-header__main-infos">
19
+ <h1
20
+ class="page-header__title"
21
+ data-testid="page-title"
22
+ >
23
+ {{ title }}
24
+ </h1>
25
+
26
+ <slot name="tag" />
27
+ </section>
28
+
29
+ <p
30
+ v-if="description"
31
+ class="page-header__description"
32
+ data-testid="page-description"
33
+ >
34
+ {{ description }}
35
+ </p>
36
+ </section>
37
+
38
+ <section
39
+ v-if="hasActionsSlot"
40
+ class="page-header__actions"
41
+ data-testid="page-actions"
42
+ >
43
+ <slot name="actions" />
44
+ </section>
45
+
46
+ <section
47
+ v-if="hasTabsSlot"
48
+ class="page-header__tabs"
49
+ data-testid="page-tabs"
50
+ >
51
+ <slot name="tabs" />
52
+ </section>
53
+ </header>
54
+ </template>
55
+
56
+ <script setup lang="ts">
57
+ import { useSlots } from 'vue';
58
+
59
+ import UnnnicButton from '../Button/Button.vue';
60
+
61
+ import type { PageHeaderProps, PageHeaderEmits } from './types';
62
+
63
+ withDefaults(defineProps<PageHeaderProps>(), {
64
+ description: '',
65
+ hasBackButton: false,
66
+ });
67
+
68
+ const emit = defineEmits<PageHeaderEmits>();
69
+
70
+ const slots = useSlots();
71
+ const hasActionsSlot = !!slots.actions;
72
+ const hasTabsSlot = !!slots.tabs;
73
+
74
+ const handleBackClick = (): void => {
75
+ emit('back');
76
+ };
77
+ </script>
78
+
79
+ <style lang="scss" scoped>
80
+ @use '@/assets/scss/unnnic' as *;
81
+
82
+ * {
83
+ margin: 0;
84
+ padding: 0;
85
+ box-sizing: border-box;
86
+ }
87
+
88
+ .page-header {
89
+ width: 100%;
90
+
91
+ margin-top: $unnnic-space-2;
92
+ padding-bottom: $unnnic-space-6;
93
+
94
+ display: grid;
95
+ gap: $unnnic-space-4;
96
+ grid-template-columns: 1fr minmax(250px, 20%); // TODO: Verify if is 250px or 20% (8fr 2fr)
97
+ align-items: center;
98
+
99
+ border-bottom: 1px solid $unnnic-color-border-soft;
100
+
101
+ &--has-back-button {
102
+ grid-template-columns: auto 1fr minmax(250px, 20%);
103
+ }
104
+
105
+ &--has-tabs {
106
+ border-bottom: none;
107
+ }
108
+
109
+ &__infos {
110
+ display: flex;
111
+ flex-direction: column;
112
+ gap: $unnnic-space-2;
113
+ }
114
+
115
+ &__main-infos {
116
+ display: flex;
117
+ align-items: center;
118
+ gap: $unnnic-space-2;
119
+ }
120
+
121
+ &__title {
122
+ overflow: hidden;
123
+ text-overflow: ellipsis;
124
+ white-space: nowrap;
125
+
126
+ color: $unnnic-color-fg-emphasized;
127
+ text-overflow: ellipsis;
128
+
129
+ font: $unnnic-font-display-1;
130
+ }
131
+
132
+ &__description {
133
+ color: $unnnic-color-fg-base;
134
+
135
+ font: $unnnic-font-body;
136
+ }
137
+
138
+ &__actions {
139
+ display: flex;
140
+ gap: $unnnic-space-2;
141
+ align-items: center;
142
+ justify-content: flex-end;
143
+
144
+ > * {
145
+ width: 100%;
146
+ }
147
+ }
148
+
149
+ &__tabs {
150
+ grid-column: 1 / -1;
151
+ grid-row: 2 / 3;
152
+ }
153
+ }
154
+ </style>
@@ -0,0 +1,2 @@
1
+ export { default } from './PageHeader.vue';
2
+ export { default as PageHeader } from './PageHeader.vue';
@@ -0,0 +1,10 @@
1
+ export interface PageHeaderProps {
2
+ title: string;
3
+ description?: string;
4
+
5
+ hasBackButton?: boolean;
6
+ }
7
+
8
+ export interface PageHeaderEmits {
9
+ (event: 'back'): void;
10
+ }
@@ -62,6 +62,7 @@ const color = computed(() => {
62
62
  gap: $unnnic-space-1;
63
63
  border-radius: $unnnic-border-radius-pill;
64
64
  padding: calc($unnnic-space-1 * 1.5) $unnnic-space-3;
65
+ width: fit-content;
65
66
 
66
67
  background-color: v-bind(color);
67
68
 
@@ -72,6 +73,10 @@ const color = computed(() => {
72
73
  &__label {
73
74
  margin: 0;
74
75
 
76
+ overflow: hidden;
77
+ text-overflow: ellipsis;
78
+ white-space: nowrap;
79
+
75
80
  font: $unnnic-font-caption-1;
76
81
  color: $unnnic-color-fg-emphasized;
77
82
  }
@@ -93,16 +93,17 @@ import DataTable from './DataTable/index.vue';
93
93
  import Chip from './Chip/Chip.vue';
94
94
  import Toast from './Toast/Toast.vue';
95
95
  import { toast } from './Toast/ToastManager';
96
- import Tabs from './ui/tabs/Tabs.vue';
97
- import TabsList from './ui/tabs/TabsList.vue';
98
- import TabsTrigger from './ui/tabs/TabsTrigger.vue';
99
- import TabsContent from './ui/tabs/TabsContent.vue';
100
96
  import Popover from './ui/popover/Popover.vue';
101
97
  import PopoverContent from './ui/popover/PopoverContent.vue';
102
98
  import PopoverTrigger from './ui/popover/PopoverTrigger.vue';
103
99
  import PopoverFooter from './ui/popover/PopoverFooter.vue';
104
100
  import TemplatePreview from './TemplatePreview/TemplatePreview.vue';
105
101
  import TemplatePreviewModal from './TemplatePreview/TemplatePreviewModal.vue';
102
+ import Tabs from './ui/tabs/Tabs.vue';
103
+ import TabsList from './ui/tabs/TabsList.vue';
104
+ import TabsTrigger from './ui/tabs/TabsTrigger.vue';
105
+ import TabsContent from './ui/tabs/TabsContent.vue';
106
+ import PageHeader from './PageHeader/PageHeader.vue';
106
107
 
107
108
  type VueComponent = Component;
108
109
 
@@ -208,13 +209,14 @@ export const components: ComponentsMap = {
208
209
  unnnicChip: Chip,
209
210
  unnnicToast: Toast,
210
211
  unnnicToastManager: toast,
212
+ unnnicPopover: Popover,
213
+ unnnicPopoverContent: PopoverContent,
214
+ unnnicPopoverTrigger: PopoverTrigger,
211
215
  unnnicTabs: Tabs,
212
216
  unnnicTabsList: TabsList,
213
217
  unnnicTabsTrigger: TabsTrigger,
214
218
  unnnicTabsContent: TabsContent,
215
- unnnicPopover: Popover,
216
- unnnicPopoverContent: PopoverContent,
217
- unnnicPopoverTrigger: PopoverTrigger,
219
+ unnnicPageHeader: PageHeader,
218
220
  };
219
221
 
220
222
  export const unnnicFontSize = fontSize;
@@ -313,16 +315,17 @@ export const unnnicSelectTime = SelectTime as VueComponent;
313
315
  export const unnnicChip = Chip;
314
316
  export const unnnicToast = Toast;
315
317
  export const unnnicToastManager = toast;
316
- export const unnnicTabs = Tabs;
317
- export const unnnicTabsList = TabsList;
318
- export const unnnicTabsTrigger = TabsTrigger;
319
- export const unnnicTabsContent = TabsContent;
320
318
  export const unnnicPopover = Popover;
321
319
  export const unnnicPopoverContent = PopoverContent;
322
320
  export const unnnicPopoverTrigger = PopoverTrigger;
323
321
  export const unnnicPopoverFooter = PopoverFooter;
324
322
  export const unnnicTemplatePreview = TemplatePreview as VueComponent;
325
323
  export const unnnicTemplatePreviewModal = TemplatePreviewModal as VueComponent;
324
+ export const unnnicTabs = Tabs;
325
+ export const unnnicTabsList = TabsList;
326
+ export const unnnicTabsTrigger = TabsTrigger;
327
+ export const unnnicTabsContent = TabsContent;
328
+ export const unnnicPageHeader = PageHeader;
326
329
 
327
330
  export const UnnnicFontSize = fontSize;
328
331
  export const UnnnicInput = input;
@@ -419,13 +422,14 @@ export const UnnnicSelectTime = SelectTime as VueComponent;
419
422
  export const UnnnicChip = Chip;
420
423
  export const UnnnicToast = Toast;
421
424
  export const UnnnicToastManager = toast;
422
- export const UnnnicTabs = Tabs;
423
- export const UnnnicTabsList = TabsList;
424
- export const UnnnicTabsTrigger = TabsTrigger;
425
- export const UnnnicTabsContent = TabsContent;
426
425
  export const UnnnicPopover = Popover;
427
426
  export const UnnnicPopoverContent = PopoverContent;
428
427
  export const UnnnicPopoverTrigger = PopoverTrigger;
429
428
  export const UnnnicPopoverFooter = PopoverFooter;
430
429
  export const UnnnicTemplatePreview = TemplatePreview as VueComponent;
431
430
  export const UnnnicTemplatePreviewModal = TemplatePreviewModal as VueComponent;
431
+ export const UnnnicTabs = Tabs;
432
+ export const UnnnicTabsList = TabsList;
433
+ export const UnnnicTabsTrigger = TabsTrigger;
434
+ export const UnnnicTabsContent = TabsContent;
435
+ export const UnnnicPageHeader = PageHeader;
@@ -0,0 +1,330 @@
1
+ import { action } from '@storybook/addon-actions';
2
+
3
+ import PageHeader from '../components/PageHeader/PageHeader.vue';
4
+ import UnnnicButton from '../components/Button/Button.vue';
5
+ import UnnnicTag from '../components/Tag/Tag.vue';
6
+ import UnnnicSelectSmart from '../components/SelectSmart/SelectSmart.vue';
7
+ import { Tabs, TabsList, TabsTrigger, TabsContent } from '@/components/ui/tabs';
8
+
9
+ export default {
10
+ title: 'Layout/PageHeader',
11
+ component: PageHeader,
12
+ tags: ['autodocs'],
13
+ parameters: {
14
+ docs: {
15
+ description: {
16
+ component: `A page header component to standardize the header of pages.
17
+ <br/>
18
+ It supports title, description, actions, tabs, tags, and back navigation.
19
+ <br/>
20
+ This component provides multiple variations to handle different page header scenarios.
21
+ `,
22
+ },
23
+ },
24
+ },
25
+ argTypes: {
26
+ title: {
27
+ control: { type: 'text' },
28
+ description: 'The title of the page',
29
+ },
30
+ description: {
31
+ control: { type: 'text' },
32
+ description: 'The description text below the title',
33
+ },
34
+ hasBackButton: {
35
+ control: { type: 'boolean' },
36
+ description: 'Show back navigation button',
37
+ },
38
+ },
39
+ args: {
40
+ title: 'Page Name',
41
+ description: 'Description',
42
+ hasBackButton: false,
43
+ },
44
+ };
45
+
46
+ export const Default = {
47
+ parameters: {
48
+ docs: {
49
+ description: {
50
+ story: 'A simple page header with title and description.',
51
+ },
52
+ source: {
53
+ code: `
54
+ <UnnnicPageHeader
55
+ title="Page Name"
56
+ description="Description"
57
+ />
58
+ `,
59
+ },
60
+ },
61
+ },
62
+ render: (args) => ({
63
+ components: { PageHeader },
64
+ setup() {
65
+ return { args };
66
+ },
67
+ template: `
68
+ <PageHeader v-bind="args" />
69
+ `,
70
+ }),
71
+ };
72
+
73
+ export const WithActions = {
74
+ parameters: {
75
+ docs: {
76
+ description: {
77
+ story:
78
+ 'Page header with action buttons on the right side. Supports primary and secondary actions.',
79
+ },
80
+ source: {
81
+ code: `
82
+ <UnnnicPageHeader
83
+ title="Page Name"
84
+ description="Description"
85
+ >
86
+ <template #actions>
87
+ <UnnnicButton text="Button" type="secondary" />
88
+ <UnnnicButton text="Button" type="primary" />
89
+ </template>
90
+ </UnnnicPageHeader>
91
+ `,
92
+ },
93
+ },
94
+ },
95
+ render: (args) => ({
96
+ components: {
97
+ PageHeader,
98
+ UnnnicButton,
99
+ Tabs,
100
+ TabsList,
101
+ TabsTrigger,
102
+ TabsContent,
103
+ },
104
+ setup() {
105
+ return { args };
106
+ },
107
+ template: `
108
+ <PageHeader v-bind="args">
109
+ <template #actions>
110
+ <UnnnicButton text="Button" type="secondary" />
111
+ <UnnnicButton text="Button" type="primary" />
112
+ </template>
113
+ </PageHeader>
114
+ `,
115
+ }),
116
+ };
117
+
118
+ export const WithTabs = {
119
+ parameters: {
120
+ docs: {
121
+ description: {
122
+ story:
123
+ 'Page header with tabs for navigation. Useful for pages with multiple sections divided by tabs.',
124
+ },
125
+ source: {
126
+ code: `
127
+ <UnnnicPageHeader
128
+ title="Page Name"
129
+ description="Description"
130
+ >
131
+ <template #actions>
132
+ <UnnnicButton text="Button" type="secondary" />
133
+ <UnnnicButton text="Button" type="primary" />
134
+ </template>
135
+ <template #tabs>
136
+ <UnnnicTabs defaultValue="label1">
137
+ <UnnnicTabsList>
138
+ <UnnnicTabsTrigger value="label1">Label</UnnnicTabsTrigger>
139
+ <UnnnicTabsTrigger value="label2">Label</UnnnicTabsTrigger>
140
+ <UnnnicTabsTrigger value="label3">Label</UnnnicTabsTrigger>
141
+ </UnnnicTabsList>
142
+ </UnnnicTabs>
143
+ </template>
144
+ </UnnnicPageHeader>
145
+ `,
146
+ },
147
+ },
148
+ },
149
+ render: (args) => ({
150
+ components: {
151
+ PageHeader,
152
+ UnnnicButton,
153
+ Tabs,
154
+ TabsList,
155
+ TabsTrigger,
156
+ TabsContent,
157
+ },
158
+ setup() {
159
+ return { args };
160
+ },
161
+ template: `
162
+ <PageHeader v-bind="args">
163
+ <template #actions>
164
+ <UnnnicButton text="Button" type="secondary" />
165
+ <UnnnicButton text="Button" type="primary" />
166
+ </template>
167
+ <template #tabs>
168
+ <Tabs defaultValue="label1">
169
+ <TabsList>
170
+ <TabsTrigger value="label1">Label</TabsTrigger>
171
+ <TabsTrigger value="label2">Label</TabsTrigger>
172
+ <TabsTrigger value="label3">Label</TabsTrigger>
173
+ </TabsList>
174
+ </Tabs>
175
+ </template>
176
+ </PageHeader>
177
+ `,
178
+ }),
179
+ };
180
+
181
+ export const WithSelect = {
182
+ parameters: {
183
+ docs: {
184
+ description: {
185
+ story: 'Page header with a select dropdown on the right side.',
186
+ },
187
+ source: {
188
+ code: `
189
+ <UnnnicPageHeader
190
+ title="Page Name"
191
+ description="Description"
192
+ >
193
+ <template #actions>
194
+ <UnnnicSelectSmart />
195
+ </template>
196
+ </UnnnicPageHeader>
197
+ `,
198
+ },
199
+ },
200
+ },
201
+ render: (args) => ({
202
+ components: { PageHeader, UnnnicSelectSmart },
203
+ setup() {
204
+ return { args };
205
+ },
206
+ template: `
207
+ <PageHeader v-bind="args">
208
+ <template #actions>
209
+ <UnnnicSelectSmart />
210
+ </template>
211
+ </PageHeader>
212
+ `,
213
+ }),
214
+ };
215
+
216
+ export const WithTag = {
217
+ parameters: {
218
+ docs: {
219
+ description: {
220
+ story: 'Page header with a tag next to the title and action buttons.',
221
+ },
222
+ source: {
223
+ code: `
224
+ <UnnnicPageHeader
225
+ title="Page Name"
226
+ description="Description"
227
+ >
228
+ <template #tag>
229
+ <UnnnicTag text="Tag name" scheme="gray" />
230
+ </template>
231
+ <template #actions>
232
+ <UnnnicButton text="Button" type="secondary" />
233
+ <UnnnicButton text="Button" type="primary" />
234
+ </template>
235
+ </UnnnicPageHeader>
236
+ `,
237
+ },
238
+ },
239
+ },
240
+ render: (args) => ({
241
+ components: { PageHeader, UnnnicButton, UnnnicTag },
242
+ setup() {
243
+ return { args };
244
+ },
245
+ template: `
246
+ <PageHeader v-bind="args">
247
+ <template #tag>
248
+ <UnnnicTag text="Tag name" scheme="gray" />
249
+ </template>
250
+ <template #actions>
251
+ <UnnnicButton text="Button" type="secondary" />
252
+ <UnnnicButton text="Button" type="primary" />
253
+ </template>
254
+ </PageHeader>
255
+ `,
256
+ }),
257
+ };
258
+
259
+ export const WithMenuButton = {
260
+ parameters: {
261
+ docs: {
262
+ description: {
263
+ story: 'Page header with a menu button (three dots) on the right side.',
264
+ },
265
+ source: {
266
+ code: `
267
+ <UnnnicPageHeader
268
+ title="Page Name"
269
+ description="Description"
270
+ >
271
+ <template #actions>
272
+ <UnnnicButton type="tertiary" iconCenter="more_vert" />
273
+ </template>
274
+ </UnnnicPageHeader>
275
+ `,
276
+ },
277
+ },
278
+ },
279
+ render: (args) => ({
280
+ components: { PageHeader, UnnnicButton },
281
+ setup() {
282
+ return { args };
283
+ },
284
+ template: `
285
+ <PageHeader v-bind="args">
286
+ <template #actions>
287
+ <UnnnicButton type="tertiary" iconCenter="more_vert" />
288
+ </template>
289
+ </PageHeader>
290
+ `,
291
+ }),
292
+ };
293
+
294
+ export const WithBackButton = {
295
+ parameters: {
296
+ docs: {
297
+ description: {
298
+ story: 'Page header with a back navigation button.',
299
+ },
300
+ source: {
301
+ code: `
302
+ <UnnnicPageHeader
303
+ title="Page Name"
304
+ :hasBackButton="true"
305
+ />
306
+ `,
307
+ },
308
+ },
309
+ },
310
+ render: (args) => ({
311
+ components: { PageHeader },
312
+ setup() {
313
+ const handleBack = () => {
314
+ action('back')();
315
+ };
316
+
317
+ return {
318
+ args: {
319
+ ...args,
320
+ hasBackButton: true,
321
+ description: '',
322
+ },
323
+ handleBack,
324
+ };
325
+ },
326
+ template: `
327
+ <PageHeader v-bind="args" @back="handleBack" />
328
+ `,
329
+ }),
330
+ };