Skip to content

Commit 697a615

Browse files
committed
Merge remote-tracking branch 'origin/dev' into bugfix/uui-box-align-slots-and-styling
# Conflicts: # packages/uui-box/lib/uui-box.element.ts
2 parents 8681f44 + c7048d9 commit 697a615

File tree

46 files changed

+501
-376
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

46 files changed

+501
-376
lines changed

.storybook/preview.js

Lines changed: 32 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,10 @@
1-
import { setCustomElements } from '@storybook/web-components';
2-
import customElements from '../custom-elements.json';
31
import '../packages/uui-css/lib/uui-css.css';
42
import 'element-internals-polyfill';
53

4+
import { setCustomElements } from '@storybook/web-components';
5+
6+
import customElements from '../custom-elements.json';
7+
68
const sort = (a, b) => {
79
if (a[1].name === 'Overview') {
810
return 0;
@@ -44,4 +46,32 @@ export const parameters = {
4446
},
4547
};
4648

49+
WebComponentFormatter(customElements);
50+
4751
setCustomElements(customElements);
52+
53+
function WebComponentFormatter(customElements) {
54+
for (let tag of customElements.tags || []) {
55+
// Find all names of properties
56+
const propertyNames = (tag.properties || []).map(p => p.name);
57+
58+
for (let slot of tag.slots || []) {
59+
// Replace the name of the default slot so Storybook will show it
60+
if (typeof slot.name === 'string' && slot.name.length === 0) {
61+
slot.name = 'slot';
62+
}
63+
64+
// If the slot has the same name as a property, then add the word 'slot' to the name
65+
if (propertyNames.includes(slot.name)) {
66+
slot.name = `${slot.name} slot`;
67+
}
68+
69+
// Set type of slots
70+
if (typeof slot.type === 'undefined' || slot.type.length === 0) {
71+
slot.type = 'HTMLElement';
72+
}
73+
}
74+
}
75+
76+
return customElements;
77+
}

packages/uui-avatar-group/lib/uui-avatar-group.element.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ import { property, queryAssignedElements, state } from 'lit/decorators.js';
66
/**
77
* Group a set of avatars, set a limit to minimize the visual space.
88
* @element uui-avatar-group
9-
* @slot for uui-avatar elements
9+
* @slot - Insert the `<uui-avatar>` elements in the default slot
1010
*/
1111
@defineElement('uui-avatar-group')
1212
export class UUIAvatarGroupElement extends LitElement {

packages/uui-avatar/lib/uui-avatar.element.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
1-
import { property, state } from 'lit/decorators.js';
21
import { defineElement } from '@umbraco-ui/uui-base/lib/registration';
3-
import { LitElement, html, css } from 'lit';
2+
import { css, html, LitElement } from 'lit';
3+
import { property, state } from 'lit/decorators.js';
44

55
/**
66
* Avatar for displaying users
77
* @element uui-avatar
8-
* @slot For anything other than initials (no more than 2-3 characters)
8+
* @slot - For anything other than initials (no more than 2-3 characters)
99
*/
1010
@defineElement('uui-avatar')
1111
export class UUIAvatarElement extends LitElement {

packages/uui-avatar/lib/uui-avatar.story.ts

Lines changed: 6 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import '@umbraco-ui/uui-avatar/lib';
1+
import '.';
22

33
import { Story } from '@storybook/web-components';
44
import { html } from 'lit-html';
@@ -11,6 +11,9 @@ export default {
1111
name: 'Umbraco HQ',
1212
fontSize: 12,
1313
},
14+
argTypes: {
15+
slot: { control: { type: 'text' } },
16+
},
1417
// argTypes: {
1518
// 'img-src': { table: { disable: true } },
1619
// 'img-srcset': { table: { disable: true } },
@@ -94,11 +97,8 @@ Colors.parameters = {
9497

9598
export const SlottedContent = Template.bind({});
9699
SlottedContent.args = { slot: 'overflow', name: '' };
97-
SlottedContent.argTypes = {
98-
slot: { table: { category: 'slots' }, control: { type: 'text' } },
99-
};
100100
SlottedContent.parameters = {
101-
controls: { include: ['slot', 'overflow'] },
101+
controls: { include: ['overflow', 'slot'] },
102102
docs: {
103103
source: {
104104
code: `<uui-avatar overflow name="overflow name">overflow content</uui-avatar>`,
@@ -127,11 +127,8 @@ InlineWithText.parameters = {
127127

128128
export const WithBadge = Template.bind({});
129129
WithBadge.args = { slot: html`<uui-badge>!</uui-badge>`, overflow: true };
130-
WithBadge.argTypes = {
131-
slot: { table: { category: 'slots' }, control: { type: 'text' } },
132-
};
133130
WithBadge.parameters = {
134-
controls: { include: ['slot', 'overflow', 'name'] },
131+
controls: { include: ['overflow', 'name'] },
135132
docs: {
136133
source: {
137134
code: `<uui-avatar name="Umbraco HQ"><uui-badge>!</uui-badge></uui-avatar>`,

packages/uui-badge/lib/uui-badge.element.ts

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,12 @@
1-
import { LitElement, html, css } from 'lit';
21
import { defineElement } from '@umbraco-ui/uui-base/lib/registration';
3-
import { property } from 'lit/decorators.js';
4-
52
import { InterfaceLookType } from '@umbraco-ui/uui-base/lib/types';
3+
import { css, html, LitElement } from 'lit';
4+
import { property } from 'lit/decorators.js';
65

76
/**
87
* A badge to notify that there is something that requires attention of the user. The badge is positioned with `position: absolute`. It will determine its position against the first ancestor with `position: relative`.
98
* @element uui-badge
10-
* @slot - for badge contents
9+
* @slot - The slot for badge contents
1110
*/
1211
@defineElement('uui-badge')
1312
export class UUIBadgeElement extends LitElement {

packages/uui-badge/lib/uui-badge.story.ts

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,9 @@ export default {
2929
],
3030
control: { type: 'select' },
3131
},
32+
slot: {
33+
control: { type: 'text' },
34+
},
3235
},
3336
};
3437

@@ -101,6 +104,9 @@ WithIcon.args = {
101104
slot: html`<uui-icon name="favorite"></uui-icon>`,
102105
};
103106
WithIcon.parameters = {
107+
controls: {
108+
exclude: ['slot'],
109+
},
104110
docs: {
105111
source: {
106112
code: `

packages/uui-base/lib/mixins/FormControlMixin.ts

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import { LitElement } from 'lit';
22
import { property } from 'lit/decorators.js';
3+
34
import { UUIFormControlEvent } from '../events';
45

56
type Constructor<T = {}> = new (...args: any[]) => T;
@@ -115,7 +116,6 @@ export const FormControlMixin = <T extends Constructor<LitElement>>(
115116

116117
/**
117118
* Apply validation rule for requiring a value of this form control.
118-
* @type {boolean}
119119
* @attr
120120
* @default false
121121
*/
@@ -124,27 +124,21 @@ export const FormControlMixin = <T extends Constructor<LitElement>>(
124124

125125
/**
126126
* Required validation message.
127-
* @type {boolean}
128127
* @attr
129-
* @default
130128
*/
131129
@property({ type: String, attribute: 'required-message' })
132130
requiredMessage = 'This field is required';
133131

134132
/**
135133
* Apply custom error on this input.
136-
* @type {boolean}
137134
* @attr
138-
* @default false
139135
*/
140136
@property({ type: Boolean, reflect: true })
141137
error = false;
142138

143139
/**
144140
* Custom error message.
145-
* @type {boolean}
146141
* @attr
147-
* @default
148142
*/
149143
@property({ type: String, attribute: 'error-message' })
150144
errorMessage = 'This field is invalid';

packages/uui-base/lib/mixins/LabelMixin.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ export const LabelMixin = <T extends Constructor<LitElement>>(
2222
/**
2323
* Label mixin class containing the label functionality.
2424
*
25-
* @slot default - area to place the label
25+
* @slot - Override the default label
2626
*/
2727
class LabelMixinClass extends superClass {
2828
/**

packages/uui-box/lib/uui-box.story.ts

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,4 @@
11
import '.';
2-
import '@umbraco-ui/uui-button/lib';
3-
import '@umbraco-ui/uui-input/lib';
42

53
import { Story } from '@storybook/web-components';
64
import { html } from 'lit-html';

packages/uui-breadcrumbs/lib/uui-breadcrumb-item.element.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ import { property } from 'lit/decorators.js';
55
/**
66
* A breadcrumb-item to be used with the breadcrumbs component.
77
* @element uui-breadcrumb-item
8-
* @slot - to show display an element inside the breadcrumb
8+
* @slot - This slot displays elements inside the breadcrumb
99
* @csspart separator - change the content of the after element of this part to change the separator
1010
*/
1111
@defineElement('uui-breadcrumb-item')

0 commit comments

Comments
 (0)