Skip to content

Commit e48a720

Browse files
authored
[TASK] Removed preview and button features (#9)
1 parent 0d5c86f commit e48a720

2 files changed

Lines changed: 47 additions & 227 deletions

File tree

src/index.html

Lines changed: 0 additions & 106 deletions
Original file line numberDiff line numberDiff line change
@@ -36,110 +36,4 @@ <h2>Prod</h2>
3636
</typo3-universe>
3737
</div>
3838

39-
<h2>Preview</h2>
40-
41-
<div style="margin: 1rem 0;">
42-
<typo3-universe
43-
active="typo3"
44-
menu='[
45-
{
46-
"id": "typo3",
47-
"label": "TYPO3",
48-
"href": "#"
49-
},
50-
{
51-
"id": "community",
52-
"label": "Community",
53-
"href": "#"
54-
},
55-
{
56-
"id": "ecosystem",
57-
"label": "Ecosystem",
58-
"href": "#"
59-
},
60-
{
61-
"id": "newsevents",
62-
"label": "News & Events",
63-
"href": "#"
64-
},
65-
{
66-
"id": "spacer",
67-
"type": "spacer"
68-
},
69-
{
70-
"id": "documentation",
71-
"label": "Documentation",
72-
"href": "#"
73-
},
74-
{
75-
"id": "mytypo3",
76-
"label": "My TYPO3",
77-
"href": "#"
78-
},
79-
{
80-
"id": "download",
81-
"label": "Get TYPO3",
82-
"href": "#",
83-
"icon": "<svg xmlns=\"http://www.w3.org/2000/svg\" width=\"16\" height=\"16\" viewBox=\"0 0 16 16\"><g fill=\"currentColor\"><path d=\"M14.5 9h-3.973l-.874 1H14v3H2v-3h4.346l-.873-1H1.5a.5.5 0 0 0-.5.5v4a.5.5 0 0 0 .5.5h13a.5.5 0 0 0 .5-.5v-4a.5.5 0 0 0-.5-.5z\"/><path d=\"M10 11h1v1h-1zM12 11h1v1h-1zM11.27 6H4.73a.25.25 0 0 0-.188.414l3.27 3.743a.244.244 0 0 0 .377 0l3.27-3.743A.25.25 0 0 0 11.27 6z\"/><path d=\"M7 2h2v4H7z\"/></g></svg>"
84-
}
85-
]'
86-
preview
87-
>
88-
<!-- Fallback to consume the defined space on loading and no component support -->
89-
<div style="display: block; height: 44px; background-color: #313131;"></div>
90-
</typo3-universe>
91-
</div>
92-
93-
<div style="margin: 1rem 0;" dir="rtl">
94-
<typo3-universe
95-
active="community"
96-
menu='[
97-
{
98-
"id": "typo3",
99-
"label": "TYPO3",
100-
"href": "#"
101-
},
102-
{
103-
"id": "community",
104-
"label": "Community",
105-
"href": "#"
106-
},
107-
{
108-
"id": "ecosystem",
109-
"label": "Ecosystem",
110-
"href": "#"
111-
},
112-
{
113-
"id": "newsevents",
114-
"label": "News & Events",
115-
"href": "#"
116-
},
117-
{
118-
"id": "spacer",
119-
"type": "spacer"
120-
},
121-
{
122-
"id": "documentation",
123-
"label": "Documentation",
124-
"href": "#"
125-
},
126-
{
127-
"id": "mytypo3",
128-
"label": "My TYPO3",
129-
"href": "#"
130-
},
131-
{
132-
"id": "download",
133-
"label": "Get TYPO3",
134-
"href": "#",
135-
"icon": "<svg xmlns=\"http://www.w3.org/2000/svg\" width=\"16\" height=\"16\" viewBox=\"0 0 16 16\"><g fill=\"currentColor\"><path d=\"M14.5 9h-3.973l-.874 1H14v3H2v-3h4.346l-.873-1H1.5a.5.5 0 0 0-.5.5v4a.5.5 0 0 0 .5.5h13a.5.5 0 0 0 .5-.5v-4a.5.5 0 0 0-.5-.5z\"/><path d=\"M10 11h1v1h-1zM12 11h1v1h-1zM11.27 6H4.73a.25.25 0 0 0-.188.414l3.27 3.743a.244.244 0 0 0 .377 0l3.27-3.743A.25.25 0 0 0 11.27 6z\"/><path d=\"M7 2h2v4H7z\"/></g></svg>"
136-
}
137-
]'
138-
preview
139-
>
140-
<!-- Fallback to consume the defined space on loading and no component support -->
141-
<div style="display: block; height: 44px; background-color: #313131;"></div>
142-
</typo3-universe>
143-
</div>
144-
14539
</body>

src/typo3-universe.ts

Lines changed: 47 additions & 121 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@ import { classMap } from 'lit/directives/class-map.js';
44
import { unsafeSVG } from 'lit/directives/unsafe-svg.js';
55

66
export enum MenuEntryType {
7-
button = 'button',
87
link = 'link',
98
spacer = 'spacer'
109
}
@@ -29,55 +28,53 @@ export interface Menu {
2928
}
3029

3130
const defaultEntries : Menu = {
32-
'spacer-1': {
33-
'type': MenuEntryType.spacer,
34-
'label': '',
35-
'href': '',
36-
},
3731
'services': {
3832
'type': MenuEntryType.link,
39-
'label': 'Product',
40-
'icon': svg`<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" viewBox="0 0 16 16"><g fill="currentColor"><path d="M11.5 10.6c-.2.1-.4.1-.6.1-1.8 0-4.4-6.2-4.4-8.3 0-.8.2-1 .4-1.2-2.1.3-4.7 1.1-5.5 2.1-.2.2-.3.6-.3 1.1C1.1 7.7 4.5 15 7 15c1.1 0 3-1.8 4.5-4.4M10.4 1c2.2 0 4.5.4 4.5 1.6 0 2.6-1.6 5.7-2.5 5.7-1.5 0-3.3-4.1-3.3-6.2 0-.9.4-1.1 1.3-1.1"/></g></svg>`,
33+
'label': 'TYPO3',
4134
'href': 'https://typo3.com',
4235
},
4336
'community': {
4437
'type': MenuEntryType.link,
4538
'label': 'Community',
46-
'icon': svg`<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" viewBox="0 0 16 16"><g fill="currentColor"><path d="M5 9H3.697l-.252.168L2 10.131V3h7v1h1V2.25A.25.25 0 0 0 9.75 2h-8.5a.25.25 0 0 0-.25.25V12l3-2h1V9z"/><path d="M14 6v7.131l-1.445-.964-.252-.167H7V6h7m.75-1h-8.5a.25.25 0 0 0-.25.25v7.5c0 .138.112.25.25.25H12l3 2V5.25a.25.25 0 0 0-.25-.25z"/><path d="M8 7h5v1H8zM8 9h2v1H8z"/></g></svg>`,
39+
'href': 'https://typo3.community',
40+
},
41+
'project': {
42+
'type': MenuEntryType.link,
43+
'label': 'Project',
4744
'href': 'https://typo3.org',
4845
},
49-
'demo': {
46+
'news': {
5047
'type': MenuEntryType.link,
51-
'label': 'Demo',
52-
'icon': svg`<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" viewBox="0 0 16 16"><g fill="currentColor"><path d="M5 3.9L11.2 8 5 12.1V3.9m0-1c-.5 0-1 .4-1 1v8.3c0 .6.5 1 1 1 .2 0 .4-.1.6-.2l6.2-4.1c.6-.4.6-1.3 0-1.7L5.6 3c-.2-.1-.4-.1-.6-.1z"/></g></svg>`,
53-
'href': 'https://demo.typo3.org',
48+
'label': 'News & Events',
49+
'href': 'https://news.typo3.com',
50+
},
51+
'spacer-1': {
52+
'type': MenuEntryType.spacer,
53+
'label': '',
54+
'href': '',
5455
},
5556
'extensions': {
5657
'type': MenuEntryType.link,
5758
'label': 'Extensions',
58-
'icon': svg`<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" viewBox="0 0 16 16"><g fill="currentColor"><path d="M13.408 3.546L7.913 1.087a1.002 1.002 0 0 0-.817 0L1.592 3.545c-.36.161-.592.519-.592.914v7.102a1 1 0 0 0 .594.914l5.496 2.439a1.003 1.003 0 0 0 .812 0l5.504-2.446a1 1 0 0 0 .594-.914V4.459a1 1 0 0 0-.592-.913zM7.504 2l4.89 2.187L7.5 6.449 2.607 4.188 7.504 2zM2 5.01l5 2.31v6.46l-5-2.219V5.01zm6 8.766V7.32l5-2.31v6.545l-5 2.221z"/></g></svg>`,
5959
'href': 'https://extensions.typo3.org',
6060
},
6161
'documentation': {
6262
'type': MenuEntryType.link,
6363
'label': 'Documentation',
64-
'icon': svg`<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" viewBox="0 0 16 16"><g fill="currentColor"><path d="M13.5 1h-11c-.271 0-.5.223-.5.498v13.004c0 .278.224.498.5.498h11c.271 0 .5-.223.5-.498V1.498A.497.497 0 0 0 13.5 1zM3 2h1v12H3V2zm2 0h8v12H5V2zm1 1h6v1H6V3z" /></g></svg>`,
6564
'href': 'https://docs.typo3.org',
6665
},
6766
'shop': {
6867
'type': MenuEntryType.link,
6968
'label': 'Shop',
70-
'icon': svg`<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" viewBox="0 0 16 16"><g fill="currentColor"><path d="M5.5 12a.5.5 0 11-.001 1.001A.5.5 0 015.5 12m0-1a1.5 1.5 0 100 3 1.5 1.5 0 000-3zM11.5 12a.5.5 0 11-.001 1.001A.5.5 0 0111.5 12m0-1a1.5 1.5 0 100 3 1.5 1.5 0 000-3zM3.75 2h-2.5a.25.25 0 00-.25.25v.5c0 .138.112.25.25.25H3l1 6v1.75c0 .138.112.25.25.25h8.5a.25.25 0 00.25-.25v-.5a.25.25 0 00-.25-.25H5V9h7.82a.25.25 0 00.237-.171l1.833-5.5A.25.25 0 0014.653 3H4v-.75A.25.25 0 003.75 2zm1.097 6L4.18 4h9.433l-1.334 4H4.847z"/></g></svg>`,
7169
'href': 'https://shop.typo3.com',
7270
},
7371
'mytypo3': {
7472
'type': MenuEntryType.link,
7573
'label': 'My TYPO3',
76-
'icon': svg`<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" viewBox="0 0 16 16"><g fill="currentColor"><path d="M13 1H3c-.6 0-1 .4-1 1v12c0 .6.4 1 1 1h10c.6 0 1-.4 1-1V2c0-.6-.4-1-1-1zm0 12.8c0 .1-.1.2-.2.2H3.2c-.1 0-.2-.1-.2-.2V2.2c0-.1.1-.2.2-.2h9.5c.2 0 .3.1.3.2v11.6z"/><path d="M11.2 12c-.8-.3-1.4-.6-2-.8 0-.1-.2-.5-.2-1.2.4-.4.7-1 .7-1.4V7.4c0-.8-.6-1.4-1.5-1.4h-.4c-.8 0-1.5.6-1.5 1.4v1.1c0 .5.3 1.1.7 1.5 0 .7-.2 1.1-.2 1.2-.6.2-1.2.5-2 .8-.5.3-.8.4-.8 2h8c0-1.6-.3-1.8-.8-2zM9.5 4h-3c-.3 0-.5-.2-.5-.5s.2-.5.5-.5h3c.3 0 .5.2.5.5s-.2.5-.5.5z"/></g></svg>`,
7774
'href': 'https://my.typo3.org',
7875
},
7976
'download': {
80-
'type': MenuEntryType.button,
77+
'type': MenuEntryType.link,
8178
'label': 'Get TYPO3',
8279
'icon': svg`<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" viewBox="0 0 16 16"><g fill="currentColor"><path d="M14.5 9h-3.973l-.874 1H14v3H2v-3h4.346l-.873-1H1.5a.5.5 0 0 0-.5.5v4a.5.5 0 0 0 .5.5h13a.5.5 0 0 0 .5-.5v-4a.5.5 0 0 0-.5-.5z"/><path d="M10 11h1v1h-1zM12 11h1v1h-1zM11.27 6H4.73a.25.25 0 0 0-.188.414l3.27 3.743a.244.244 0 0 0 .377 0l3.27-3.743A.25.25 0 0 0 11.27 6z"/><path d="M7 2h2v4H7z"/></g></svg>`,
8380
'href': 'https://get.typo3.org',
@@ -110,28 +107,23 @@ const menuConverter = {
110107
export class Typo3UniverseElement extends LitElement {
111108
@property() public active: string | undefined;
112109
@property({ type: Object, converter: menuConverter }) menu: Menu = defaultEntries;
113-
@property({ type: Boolean, attribute: 'preview', reflect: true }) preview: boolean = false;
114110

115111
static styles = css`
116112
:host {
117113
--universe-zindex: 1;
118114
--universe-height: 44px;
119115
--universe-font-size: 14px;
120-
--universe-maxwidth: 1100px;
121-
--universe-text-color: #dadada;
122-
--universe-link-color: #ffffff;
123-
--universe-link-padding-horizontal: 1rem;
124-
--universe-link-padding-vertical: .5rem;
116+
--universe-maxwidth: 1430px;
117+
--universe-text-color: #fff;
118+
--universe-divider-color: #555;
119+
--universe-link-color: #fff;
120+
--universe-link-padding-horizontal: .9375rem;
121+
--universe-link-padding-vertical: .625rem;
125122
--universe-background-color: #313131;
126-
--universe-link-color: #ffffff;
123+
--universe-link-hover-color: #fff;
127124
--universe-link-background: #414141;
128-
--universe-link-hover-color: #ffffff;
129125
--universe-link-hover-background: #515151;
130126
--universe-caret-color: #ffffff;
131-
--universe-button-color: #ffffff;
132-
--universe-button-background: #ff8700;
133-
--universe-button-hover-color: #ffffff;
134-
--universe-button-hover-background: #ee7600;
135127
}
136128
137129
*,
@@ -174,6 +166,16 @@ export class Typo3UniverseElement extends LitElement {
174166
flex-grow: 1;
175167
}
176168
169+
.universe-menu-item {
170+
border-right: 1px solid var(--universe-divider-color);
171+
}
172+
173+
.universe-menu-item:has(+ .universe-menu-spacer),
174+
.universe-menu-item + .universe-menu-spacer,
175+
.universe-menu-spacer ~ .universe-menu-item {
176+
border-right: unset;
177+
}
178+
177179
.universe-item {
178180
--item-background: var(--universe-background-color);
179181
--item-color: var(--universe-text-color);
@@ -183,7 +185,7 @@ export class Typo3UniverseElement extends LitElement {
183185
background: var(--item-background);
184186
position: relative;
185187
display: flex;
186-
gap: .5em;
188+
gap: .25rem;
187189
overflow: hidden;
188190
height: var(--universe-height);
189191
align-items: center;
@@ -194,18 +196,13 @@ export class Typo3UniverseElement extends LitElement {
194196
z-index: 1;
195197
outline: none;
196198
}
197-
.universe-item:focus-visible {
198-
box-shadow:
199-
inset 0 0 0 2px var(--item-background),
200-
inset 0 0 0 4px var(--item-color);
201-
}
202199
203200
.universe-item-icon {
204201
display: block;
205202
height: 16px;
206203
width: 16px;
207204
overflow: hidden;
208-
opacity: .75;
205+
opacity: .56;
209206
}
210207
.universe-item-icon svg {
211208
display: block;
@@ -216,105 +213,35 @@ export class Typo3UniverseElement extends LitElement {
216213
transform: scaleX(-1);
217214
}
218215
219-
.universe-item--active:before {
220-
content: '';
221-
position: absolute;
222-
bottom: 0;
223-
left: 50%;
224-
height: .8em;
225-
width: .8em;
226-
transform: translate(-50%, 0);
227-
border: calc(.4em + 4px) solid transparent;
228-
border-bottom-color: var(--item-background);
229-
}
230-
231-
.universe-item--active:after {
232-
content: '';
233-
position: absolute;
234-
bottom: 0;
235-
left: 50%;
236-
height: .8em;
237-
width: .8em;
238-
transform: translate(-50%, 0);
239-
border: .4em solid transparent;
240-
border-bottom-color: var(--universe-caret-color);
241-
}
242-
243-
.universe-item--link {
244-
--item-color: var(--universe-link-color);
245-
--item-background: var(--universe-link-background);
246-
}
247-
.universe-item--link:focus,
248-
.universe-item--link:hover {
249-
--item-color: var(--universe-link-hover-color);
250-
--item-background: var(--universe-link-hover-background);
251-
}
252-
253-
.universe-item--button {
254-
--item-color: var(--universe-button-color);
255-
--item-background: var(--universe-button-background);
256-
}
257-
.universe-item--button:focus,
258-
.universe-item--button:hover {
259-
--item-color: var(--universe-button-hover-color);
260-
--item-background: var(--universe-button-hover-background);
261-
}
262-
263-
:host([preview]) {
264-
--universe-maxwidth: 1440px;
265-
--universe-text-color: #fff;
266-
--universe-divider-color: #555;
267-
--universe-link-color: #fff;
268-
--universe-link-padding-horizontal: .9375rem;
269-
--universe-link-padding-vertical: .625rem;
270-
--universe-background-color: #313130;
271-
--universe-link-color: #fff;
272-
--universe-link-background: #313130;
273-
--universe-link-hover-color: #fff;
274-
}
275-
276-
:host([preview]) .universe-menu-item {
277-
border-right: 1px solid var(--universe-divider-color);
278-
}
279-
280-
:host([preview]) .universe-menu-item:has(+ .universe-menu-spacer),
281-
:host([preview]) .universe-menu-item + .universe-menu-spacer,
282-
:host([preview]) .universe-menu-spacer ~ .universe-menu-item {
283-
border-right: unset;
284-
}
285-
286-
:host([preview]) .universe-menu-spacer ~ .universe-menu-item .universe-item {
216+
.universe-menu-spacer ~ .universe-menu-item .universe-item {
287217
--item-padding-horizontal: 10px;
288218
}
289219
290-
:host([preview]) .universe-menu-spacer ~ .universe-menu-item:last-child .universe-item {
220+
.universe-menu-spacer ~ .universe-menu-item:last-child .universe-item {
291221
padding-right: .9375rem;
292222
}
293-
:host-context([dir="rtl"]):host([preview]) .universe-menu-spacer ~ .universe-menu-item:last-child .universe-item {
223+
:host-context([dir="rtl"]) .universe-menu-spacer ~ .universe-menu-item:last-child .universe-item {
294224
padding-right: .625rem;
295225
padding-left: .9375rem;
296226
}
297227
298-
:host([preview]) .universe-menu-spacer ~ .universe-menu-item .universe-item:hover {
228+
.universe-menu-spacer ~ .universe-menu-item .universe-item:hover {
299229
--item-background: unset;
300230
text-decoration: underline;
301231
}
302232
303-
:host([preview]) .universe-item {
304-
gap: .25rem;
305-
}
306-
307-
:host([preview]) .universe-item-icon {
308-
opacity: .56;
233+
.universe-item--link {
234+
--item-color: var(--universe-link-color);
235+
--item-background: var(--universe-background-color);
309236
}
310-
311-
:host([preview]) .universe-item--active:before,
312-
:host([preview]) .universe-item--active:after {
313-
content: unset;
237+
.universe-item--link:focus,
238+
.universe-item--link:hover {
239+
--item-color: var(--universe-link-hover-color);
240+
--item-background: var(--universe-link-background);
314241
}
315242
316-
:host([preview]) .universe-item--link.universe-item--active,
317-
:host([preview]) .universe-item--link.universe-item--active:hover {
243+
.universe-item--link.universe-item--active,
244+
.universe-item--link.universe-item--active:hover {
318245
--item-background: var(--universe-text-color);
319246
--item-color: var(--universe-background-color);
320247
}
@@ -334,7 +261,6 @@ export class Typo3UniverseElement extends LitElement {
334261
<li class="universe-menu-item">
335262
<a href=${entry.href} class=${classMap({
336263
'universe-item': true,
337-
'universe-item--button': entry.type === MenuEntryType.button,
338264
'universe-item--link': entry.type === MenuEntryType.link,
339265
'universe-item--spacer': entry.type === MenuEntryType.spacer,
340266
'universe-item--active': identifier === this.active

0 commit comments

Comments
 (0)