-
Notifications
You must be signed in to change notification settings - Fork 1
Feature/update template #451
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
18 commits
Select commit
Hold shift + click to select a range
ec11581
chore: update usage of cookie drawer pattern
ermenm bc8cc6b
feat: add export of template components for templates
ermenm 3a554fe
fix: add actual theme-wizard-app import to ClienInit
ermenm 361f7b8
chore: separate file for cookie drawer
ermenm 6d1800c
chore: add enter
ermenm c7082f6
fix: logical properties
ermenm da82c8c
fix: build import cycle error
ermenm 651fd20
chore: update packages
ermenm 75591c4
feat: create clippy-heading component
ermenm 10e7083
chore: naming
ermenm e8c3cdd
fix
ermenm 769264f
feat: remove template components from theme-wizard-app
ermenm 35b836d
feat: move template-components to theme-wizard-templates
ermenm 1721835
chore: exports
ermenm 46301c7
feat: templategroup typings
ermenm 829f7ac
fix: idempotent component registration
ermenm fdbaa31
fix: closing tag
ermenm 2e3c10c
chore: cleanup
ermenm File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,5 @@ | ||
| # `<clippy-heading>` | ||
|
|
||
| Koptekst, met NL Design System heading styles. | ||
|
|
||
| Gebruik `level` (standaard `1`) om het heading level (`h1`–`h6`) te kiezen. |
66 changes: 66 additions & 0 deletions
66
packages/clippy-components/src/clippy-heading/index.test.ts
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,66 @@ | ||
|
|
||
| import { beforeEach, describe, expect, it } from 'vitest'; | ||
| import './index'; | ||
|
|
||
| const tag = 'clippy-heading'; | ||
|
|
||
| describe(`<${tag}>`, () => { | ||
| beforeEach(() => { | ||
| document.body.innerHTML = ''; | ||
| }); | ||
|
|
||
| it('renders an h1 by default', async () => { | ||
| document.body.innerHTML = `<${tag}>Hello</${tag}>`; | ||
| const component = document.querySelector(tag) as unknown as { | ||
| updateComplete: Promise<void>; | ||
| shadowRoot?: ShadowRoot; | ||
| }; | ||
| await component.updateComplete; | ||
|
|
||
| const h1 = component.shadowRoot?.querySelector('h1'); | ||
| expect(h1).toBeTruthy(); | ||
| expect(h1?.classList.contains('nl-heading')).toBe(true); | ||
| expect(h1?.classList.contains('nl-heading--level-1')).toBe(true); | ||
|
|
||
| const slot = h1?.querySelector('slot'); | ||
| const slottedText = | ||
| slot instanceof HTMLSlotElement | ||
| ? slot | ||
| .assignedNodes({ flatten: true }) | ||
| .map((n) => n.textContent ?? '') | ||
| .join('') | ||
| : ''; | ||
| expect(slottedText).toContain('Hello'); | ||
| }); | ||
|
|
||
| it('renders the requested heading level when setting the level property', async () => { | ||
| document.body.innerHTML = `<${tag}>Hello</${tag}>`; | ||
| const component = document.querySelector(tag) as unknown as { | ||
| level: number; | ||
| updateComplete: Promise<void>; | ||
| shadowRoot?: ShadowRoot; | ||
| }; | ||
|
|
||
| component.level = 2; | ||
| await component.updateComplete; | ||
|
|
||
| const h2 = component.shadowRoot?.querySelector('h2'); | ||
| expect(h2).toBeTruthy(); | ||
| expect(h2?.classList.contains('nl-heading')).toBe(true); | ||
| expect(h2?.classList.contains('nl-heading--level-2')).toBe(true); | ||
| expect(component.shadowRoot?.querySelector('h1')).toBeFalsy(); | ||
| }); | ||
|
|
||
| it('accepts the level attribute', async () => { | ||
| document.body.innerHTML = `<${tag} level="3">Hello</${tag}>`; | ||
| const component = document.querySelector(tag) as unknown as { | ||
| updateComplete: Promise<void>; | ||
| shadowRoot?: ShadowRoot; | ||
| }; | ||
| await component.updateComplete; | ||
|
|
||
| const h3 = component.shadowRoot?.querySelector('h3'); | ||
| expect(h3).toBeTruthy(); | ||
| expect(h3?.classList.contains('nl-heading--level-3')).toBe(true); | ||
| }); | ||
| }); | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,29 @@ | ||
| import headingCss from '@nl-design-system-candidate/heading-css/heading.css?inline'; | ||
| import { LitElement, unsafeCSS } from 'lit'; | ||
| import { property } from 'lit/decorators.js'; | ||
| import { html, unsafeStatic } from 'lit/static-html.js'; | ||
|
|
||
| const tag = 'clippy-heading'; | ||
|
|
||
| export class ClippyHeading extends LitElement { | ||
| @property({ type: Number }) level = 1; | ||
|
|
||
| static override readonly styles = [unsafeCSS(headingCss)]; | ||
|
|
||
| override render() { | ||
| const safeLevel = Math.min(6, Math.max(1, Number(this.level) || 1)); | ||
| const tag = unsafeStatic(`h${safeLevel}`); | ||
| return html`<${tag} class="nl-heading nl-heading--level-${safeLevel}"><slot></slot></${tag}>`; | ||
| } | ||
| } | ||
|
|
||
| const registry = globalThis.customElements; | ||
| if (registry && !registry.get(tag)) { | ||
| registry.define(tag, ClippyHeading); | ||
| } | ||
|
|
||
| declare global { | ||
| interface HTMLElementTagNameMap { | ||
| [tag]: ClippyHeading; | ||
| } | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
4 changes: 1 addition & 3 deletions
4
packages/clippy-storybook/src/GemeenteVoorbeeldHome.stories.tsx
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
72 changes: 72 additions & 0 deletions
72
packages/clippy-storybook/src/web-components/clippy-heading.stories.tsx
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,72 @@ | ||
| import type { Meta, StoryObj } from '@storybook/react-vite'; | ||
| import '@nl-design-system-community/clippy-components/clippy-heading'; | ||
| import readme from '@nl-design-system-community/clippy-components/src/clippy-heading/README.md?raw'; | ||
| import { html } from 'lit'; | ||
| import React from 'react'; | ||
| import { templateToHtml } from '../utils/templateToHtml'; | ||
|
|
||
| interface HeadingStoryArgs { | ||
| content: string; | ||
| level: number; | ||
| } | ||
|
|
||
| // Docs template builds a full <clippy-heading> element for the Source block. | ||
| const createTemplate = (level: number, content: string) => html`<clippy-heading level="${level}">${content}</clippy-heading>`; | ||
|
|
||
| const meta = { | ||
| id: 'clippy-heading', | ||
| args: { | ||
| content: 'Pagina titel', | ||
| level: 1, | ||
| }, | ||
| argTypes: { | ||
| content: { | ||
| name: 'Content', | ||
| defaultValue: '', | ||
| description: 'Text', | ||
| type: { | ||
| name: 'string', | ||
| required: true, | ||
| }, | ||
| }, | ||
| level: { | ||
| name: 'Level', | ||
| control: { max: 6, min: 1, step: 1, type: 'number' }, | ||
| defaultValue: 1, | ||
| description: 'Heading level (1–6)', | ||
| type: { | ||
| name: 'number', | ||
| required: true, | ||
| }, | ||
| }, | ||
| }, | ||
| parameters: { | ||
| docs: { | ||
| description: { | ||
| component: readme, | ||
| }, | ||
| }, | ||
| }, | ||
| render: ({ content, level }: HeadingStoryArgs) => React.createElement('clippy-heading', { level }, content), | ||
| tags: ['autodocs'], | ||
| title: 'Clippy/Heading', | ||
| } satisfies Meta<HeadingStoryArgs>; | ||
|
|
||
| export default meta; | ||
|
|
||
| type Story = StoryObj<typeof meta>; | ||
|
|
||
| export const Default: Story = { | ||
| name: 'Heading', | ||
| parameters: { | ||
| docs: { | ||
| source: { | ||
| transform: (_code: string, storyContext: { args: HeadingStoryArgs }) => { | ||
| const template = createTemplate(storyContext.args.level, storyContext.args.content); | ||
| return templateToHtml(template); | ||
| }, | ||
| type: 'code', | ||
| }, | ||
| }, | ||
| }, | ||
| }; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1 +1 @@ | ||
| import './src/components/app/app'; | ||
| import './src/components/app/app'; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
20 changes: 0 additions & 20 deletions
20
packages/theme-wizard-app/src/components/template-heading/index.ts
This file was deleted.
Oops, something went wrong.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.