-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Patrick de Klein
committed
Jan 29, 2025
1 parent
f27e3b9
commit 135847f
Showing
8 changed files
with
249 additions
and
119 deletions.
There are no files selected for viewing
This file contains 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 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,11 +1,13 @@ | ||
/* test functionality webcomponents which are tested and can be used in your project */ | ||
export * from './test-navigation'; | ||
export * from './test-next'; | ||
export * from './test-prev'; | ||
export * from './test-view'; | ||
export * from './test-item-link'; | ||
export * from './test-end-attempt'; | ||
export * from './test-show-correct-response'; | ||
export * from './test-paging-buttons-stamp'; | ||
export * from './test-navigation'; | ||
export * from './test-container'; | ||
export * from './test-print-item-variables'; | ||
export * from './test-section-buttons-stamp'; | ||
export * from './test-section-link'; |
This file contains 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 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
74 changes: 74 additions & 0 deletions
74
src/lib/qti-test/components/test-section-buttons-stamp.stories.ts
This file contains 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,74 @@ | ||
import { getWcStorybookHelpers } from 'wc-storybook-helpers'; | ||
import { html } from 'lit'; | ||
|
||
import type { Meta, StoryObj } from '@storybook/web-components'; | ||
import type { TestSectionButtonsStamp } from './test-section-buttons-stamp'; | ||
|
||
import '../../../../.storybook/utilities.css'; | ||
|
||
const { events, args, argTypes, template } = getWcStorybookHelpers('test-section-buttons-stamp'); | ||
|
||
type Story = StoryObj<TestSectionButtonsStamp & typeof args>; | ||
|
||
const meta: Meta<TestSectionButtonsStamp> = { | ||
component: 'test-section-buttons-stamp', | ||
args, | ||
argTypes, | ||
parameters: { | ||
actions: { | ||
handles: events | ||
} | ||
} | ||
}; | ||
export default meta; | ||
|
||
export const Default: Story = { | ||
render: args => | ||
html` <qti-test> | ||
<test-navigation> | ||
<test-container test-url="/assets/qti-test-package/assessment.xml"></test-container> | ||
${template( | ||
args, | ||
html`<template> | ||
<test-section-link section-id="{{ item.identifier }}"> {{ item.newIndex }} </test-section-link> | ||
</template>` | ||
)} | ||
</test-navigation> | ||
</qti-test>` | ||
}; | ||
|
||
export const Title: Story = { | ||
render: () => html` | ||
<qti-test> | ||
<test-navigation | ||
.initContext=${[ | ||
{ | ||
identifier: 'ITEM001', | ||
title: 'Test title', | ||
volgnummer: 2 | ||
}, | ||
{ | ||
identifier: 'ITEM002', | ||
title: 'Test title 2', | ||
volgnummer: 2 | ||
} | ||
]} | ||
.configContext=${{ | ||
infoItemCategory: 'info' | ||
}} | ||
.sessionContext=${{ | ||
navItemId: 'ITEM001' | ||
}} | ||
> | ||
<test-container test-url="/assets/qti-test-package/assessment.xml"></test-container> | ||
<test-section-buttons-stamp> | ||
<template> | ||
<test-section-link class="{{item.active ? 'active' : ''}}" section-id="{{ item.identifier }}"> | ||
{{ item.title }} | ||
</test-section-link> | ||
</template> | ||
</test-section-buttons-stamp> | ||
</test-navigation> | ||
</qti-test> | ||
` | ||
}; |
This file contains 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,47 @@ | ||
import { html, LitElement } from 'lit'; | ||
import { customElement } from 'lit/decorators.js'; | ||
import { prepareTemplate } from 'stampino'; | ||
import { consume } from '@lit/context'; | ||
|
||
import { computedContext } from '../../exports/computed.context'; | ||
|
||
import type { ComputedContext } from '../../exports/computed.context'; | ||
import type { TemplateFunction } from 'stampino'; | ||
|
||
@customElement('test-section-buttons-stamp') | ||
export class TestSectionButtonsStamp extends LitElement { | ||
@consume({ context: computedContext, subscribe: true }) | ||
private computedContext: ComputedContext; | ||
|
||
myTemplate: TemplateFunction; | ||
private _internals: ElementInternals; | ||
|
||
protected createRenderRoot(): HTMLElement | DocumentFragment { | ||
return this; | ||
} | ||
|
||
constructor() { | ||
super(); | ||
this._internals = this.attachInternals(); | ||
this._internals.ariaLabel = 'pagination'; | ||
} | ||
|
||
connectedCallback(): void { | ||
super.connectedCallback(); | ||
const templateElement = this.querySelector<HTMLTemplateElement>('template'); | ||
this.myTemplate = prepareTemplate(templateElement); | ||
} | ||
|
||
render() { | ||
if (!this.computedContext) return html``; | ||
const sections = this.computedContext.testParts.flatMap(testPart => testPart.sections); | ||
|
||
return html` ${sections.map(item => this.myTemplate({ item }))} `; | ||
} | ||
} | ||
|
||
declare global { | ||
interface HTMLElementTagNameMap { | ||
'test-section-buttons-stamp': TestSectionButtonsStamp; | ||
} | ||
} |
This file contains 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,47 @@ | ||
import { css, html, LitElement } from 'lit'; | ||
import { customElement, property } from 'lit/decorators.js'; | ||
|
||
import * as styles from './styles'; | ||
|
||
@customElement('test-section-link') | ||
export class TestSectionLink extends LitElement { | ||
static styles = css` | ||
:host { | ||
${styles.btn}; | ||
} | ||
:host([disabled]) { | ||
${styles.dis}; | ||
} | ||
`; | ||
|
||
@property({ type: String, attribute: 'section-id' }) | ||
private sectionId: string = null; | ||
|
||
private _requestItem(identifier: string) { | ||
this.dispatchEvent( | ||
new CustomEvent('qti-request-navigation', { | ||
composed: true, | ||
bubbles: true, | ||
detail: { | ||
type: 'section', | ||
id: identifier | ||
} | ||
}) | ||
); | ||
} | ||
|
||
constructor() { | ||
super(); | ||
this.addEventListener('click', () => this._requestItem(this.sectionId)); | ||
} | ||
|
||
render() { | ||
return html` <slot></slot> `; | ||
} | ||
} | ||
|
||
declare global { | ||
interface HTMLElementTagNameMap { | ||
'test-section-link': TestSectionLink; | ||
} | ||
} |
Oops, something went wrong.