Skip to content

Commit 99170f9

Browse files
authored
Merge branch 'v1/contrib' into feature/input-lock-border-inside-input
2 parents 2810aa5 + 4ca5066 commit 99170f9

26 files changed

+897
-28
lines changed

.eslintrc.js

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,15 @@ module.exports = {
2727
'lit/prefer-nothing': 'error',
2828
'local-rules/uui-class-prefix': 'warn',
2929
'local-rules/prefer-static-styles-last': 'warn',
30+
'no-restricted-syntax': [
31+
'warn',
32+
{
33+
message:
34+
'Elements should not be defined with customElement, use defineElement instead.',
35+
selector:
36+
'ClassDeclaration > Decorator[expression.callee.name="customElement"]',
37+
},
38+
],
3039
},
3140
parserOptions: {
3241
project: './tsconfig.json',

package-lock.json

Lines changed: 49 additions & 7 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -128,7 +128,7 @@
128128
"tsc-files": "1.1.4",
129129
"turbo": "1.10.15",
130130
"typescript": "5.2.2",
131-
"vite": "5.0.4",
131+
"vite": "5.0.5",
132132
"vite-tsconfig-paths": "4.2.0",
133133
"web-component-analyzer": "1.1.7"
134134
},

packages/uui-base/lib/utils/index.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,3 +3,4 @@ export * from './demandCustomElement';
33
export * from './drag';
44
export * from './math';
55
export * from './findAncestorByAttributeValue';
6+
export * from './slotHasContent';
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
export function slotHasContent(target: EventTarget | null): boolean {
2+
return target
3+
? (target as HTMLSlotElement).assignedNodes({ flatten: true }).length > 0
4+
: false;
5+
}

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,8 +32,8 @@ export default {
3232
const Template: Story = props => {
3333
return html`
3434
<uui-box
35-
.headline=${props.headline}
36-
.headlineVariant=${props.headlineVariant}>
35+
headline="${props.headline}"
36+
headline-variant="${props.headlineVariant}">
3737
<p>Some content of this box, appended in the default slot.</p>
3838
<p>The headline is currently rendered as a ${props.headlineVariant}.</p>
3939
</uui-box>
Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
# uui-card-block-type
2+
3+
![npm](https://img.shields.io/npm/v/@umbraco-ui/uui-card-block-type?logoColor=%231B264F)
4+
5+
Umbraco style card-block-type component.
6+
7+
## Installation
8+
9+
### ES imports
10+
11+
```zsh
12+
npm i @umbraco-ui/uui-card-block-type
13+
```
14+
15+
Import the registration of `<uui-card-block-type>` via:
16+
17+
```javascript
18+
import '@umbraco-ui/uui-card-block-type';
19+
```
20+
21+
When looking to leverage the `UUICardBlockTypeElement` base class as a type and/or for extension purposes, do so via:
22+
23+
```javascript
24+
import { UUICardBlockTypeElement } from '@umbraco-ui/uui-card-block-type';
25+
```
26+
27+
## Usage
28+
29+
```html
30+
<uui-card-block-type></uui-card-block-type>
31+
```
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
export * from './uui-card-block-type.element';
Lines changed: 188 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,188 @@
1+
import { defineElement } from '@umbraco-ui/uui-base/lib/registration';
2+
import { css, html, nothing } from 'lit';
3+
import { UUICardElement } from '@umbraco-ui/uui-card/lib';
4+
import { styleMap } from 'lit/directives/style-map.js';
5+
import { ifDefined } from 'lit/directives/if-defined.js';
6+
7+
import { property } from 'lit/decorators.js';
8+
9+
export type BlockTypeIcon = {
10+
name?: string;
11+
color?: string;
12+
};
13+
14+
/**
15+
* @element uui-card-block-type
16+
*/
17+
@defineElement('uui-card-block-type')
18+
export class UUICardBlockTypeElement extends UUICardElement {
19+
/**
20+
* Block type name
21+
* @type {string}
22+
* @attr name
23+
* @default ''
24+
*/
25+
@property({ type: String })
26+
name = '';
27+
28+
/**
29+
* Block type description
30+
* @type {string}
31+
* @attr description
32+
* @default undefined
33+
*/
34+
@property({ type: String })
35+
description?: string;
36+
37+
@property({ type: String, attribute: 'background' })
38+
background?: string;
39+
40+
render() {
41+
return html`
42+
<div
43+
id="portrait"
44+
style=${styleMap({ backgroundColor: this.background })}>
45+
<slot></slot>
46+
</div>
47+
${this.href ? this.#renderLink() : this.#renderButton()}
48+
49+
<slot name="tag"></slot>
50+
<slot name="actions"></slot>
51+
`;
52+
}
53+
54+
#renderButton() {
55+
return html`
56+
<button
57+
id="open-part"
58+
tabindex=${this.disabled ? (nothing as any) : '0'}
59+
@click=${this.handleOpenClick}
60+
@keydown=${this.handleOpenKeydown}>
61+
<strong>${this.name}</strong><small>${this.description}</small>
62+
</button>
63+
`;
64+
}
65+
66+
#renderLink() {
67+
return html`
68+
<a
69+
id="open-part"
70+
tabindex=${this.disabled ? (nothing as any) : '0'}
71+
href=${ifDefined(!this.disabled ? this.href : undefined)}
72+
target=${ifDefined(this.target || undefined)}
73+
rel=${ifDefined(
74+
this.target === '_blank' ? 'noopener noreferrer' : undefined
75+
)}>
76+
<strong>${this.name}</strong><small>${this.description}</small>
77+
</a>
78+
`;
79+
}
80+
81+
static styles = [
82+
...UUICardElement.styles,
83+
css`
84+
:host {
85+
flex-direction: column;
86+
justify-content: flex-start;
87+
}
88+
89+
:host(:hover) #info {
90+
color: var(--uui-color-interactive-emphasis);
91+
}
92+
93+
#portrait {
94+
background-color: var(--uui-color-surface-alt);
95+
display: flex;
96+
justify-content: center;
97+
min-height: 150px;
98+
max-height: 150px;
99+
}
100+
101+
slot:not([name])::slotted(*) {
102+
align-self: center;
103+
font-size: var(--uui-size-8);
104+
border-radius: var(--uui-border-radius);
105+
object-fit: cover;
106+
max-width: 100%;
107+
max-height: 100%;
108+
}
109+
110+
#open-part {
111+
text-align: left;
112+
background-color: var(--uui-color-surface);
113+
cursor: pointer;
114+
color: var(--uui-color-interactive);
115+
border: none;
116+
border-top: 1px solid var(--uui-color-divider);
117+
border-radius: 0 0 var(--uui-border-radius) var(--uui-border-radius);
118+
font-family: inherit;
119+
font-size: var(--uui-type-small-size);
120+
box-sizing: border-box;
121+
padding: var(--uui-size-2) var(--uui-size-4);
122+
display: flex;
123+
flex-direction: column;
124+
line-height: var(--uui-size-6);
125+
}
126+
127+
:host([disabled]) #open-part {
128+
pointer-events: none;
129+
background: var(--uui-color-disabled);
130+
color: var(--uui-color-contrast-disabled);
131+
}
132+
133+
#open-part:hover strong {
134+
text-decoration: underline;
135+
}
136+
#open-part:hover {
137+
color: var(--uui-color-interactive-emphasis);
138+
}
139+
140+
:host([image]:not([image=''])) #open-part {
141+
transition: opacity 0.5s 0.5s;
142+
opacity: 0;
143+
}
144+
slot[name='tag'] {
145+
position: absolute;
146+
top: var(--uui-size-4);
147+
right: var(--uui-size-4);
148+
display: flex;
149+
justify-content: right;
150+
}
151+
152+
slot[name='actions'] {
153+
position: absolute;
154+
top: var(--uui-size-4);
155+
right: var(--uui-size-4);
156+
display: flex;
157+
justify-content: right;
158+
159+
opacity: 0;
160+
transition: opacity 120ms;
161+
}
162+
:host(:focus) slot[name='actions'],
163+
:host(:focus-within) slot[name='actions'],
164+
:host(:hover) slot[name='actions'] {
165+
opacity: 1;
166+
}
167+
168+
:host(
169+
[image]:not([image='']):hover,
170+
[image]:not([image='']):focus,
171+
[image]:not([image='']):focus-within,
172+
[selected][image]:not([image='']),
173+
[error][image]:not([image=''])
174+
)
175+
#open-part {
176+
opacity: 1;
177+
transition-duration: 120ms;
178+
transition-delay: 0s;
179+
}
180+
`,
181+
];
182+
}
183+
184+
declare global {
185+
interface HTMLElementTagNameMap {
186+
'uui-card-block-type': UUICardBlockTypeElement;
187+
}
188+
}

0 commit comments

Comments
 (0)