File

packages/ecl/components/ecl-quiz/ecl-quiz-card.component.ts

Description

ECL Quiz Card component – represents a single card in the quiz.

For the 'reveal' variant, the entire card is clickable to flip. For the 'poll' variant, individual options trigger the flip.

Extends

ECLBaseDirective

Metadata

Index

Properties
Methods
Inputs
Outputs
Accessors

Inputs

answer
Type : string
Default value : ''

The answer text displayed on the back of the card. Used in 'reveal' variant or as explanation in 'poll' variant.

answerTitle
Type : string
Default value : ''

The answer title (e.g. "The correct answer is A.") for poll variant.

category
Type : string
Default value : ''

Category label displayed in the card header (poll variant).

icon
Type : string
Default value : ''

Icon name for the card header. Defaults to 'sparkle' for reveal, 'question' for poll.

iconSize
Type : "xs" | "s" | "m" | "l" | "xl" | "2xl"
Default value : 'xl'

Icon size for the card header.

id
Type : string
Default value : `ecl-quiz-card-${crypto.randomUUID()}`

Unique identifier for the card, used for accessibility attributes. If not provided, a unique ID is generated automatically.

options
Type : Array<{ text: string; match: boolean }>
Default value : []

Options for the poll variant. Each option has text and a match flag.

question
Type : string
Default value : ''

The question text displayed on the front of the card.

class
Type : string
e2eAttr
Type : any
tabindex
Type : number

Outputs

cardFlip
Type : EventEmitter

Emitted when the card is flipped.

Methods

flipCard
flipCard()

Flip the card between front and back.

Returns : void
getAnswerElement
getAnswerElement()

Get the native answer element for height calculations.

Returns : HTMLElement | null
getBackElement
getBackElement()

Get the native back element for height calculations.

Returns : HTMLElement | null
getContentElement
getContentElement()

Get the native content element for height calculations.

Returns : HTMLElement | null
getFrontElement
getFrontElement()

Get the native front element for height calculations.

Returns : HTMLElement | null
getIconName
getIconName()

Get the resolved icon name based on variant.

Returns : string
getIconSize
getIconSize()

Get the resolved icon size.

Returns : string
getQuestionElement
getQuestionElement()

Get the native question element for height calculations.

Returns : HTMLElement | null
onClick
onClick()

Handle click on the card itself (reveal variant).

Returns : void
onKeydown
onKeydown(event: KeyboardEvent)

Handle keyboard events (Enter/Space to flip for reveal variant).

Parameters :
Name Type Optional
event KeyboardEvent No
Returns : void
onOptionClick
onOptionClick(optionIndex: number)

Handle option click (poll variant).

Parameters :
Name Type Optional
optionIndex number No
Returns : void
onOptionKeydown
onOptionKeydown(event: KeyboardEvent, optionIndex: number)

Handle keyboard on option (poll variant).

Parameters :
Name Type Optional
event KeyboardEvent No
optionIndex number No
Returns : void
getCssClasses
getCssClasses(rootClass: string)
Parameters :
Name Type Optional
rootClass string No
Returns : string

Properties

answerElementRef
Type : ElementRef
Decorators :
@ViewChild('answerElement')
answerId
Type : unknown
Default value : computed(() => `${this.id()}-answer`)

Unique identifier for the answer element.

backElementRef
Type : ElementRef
Decorators :
@ViewChild('backElement')
contentElementRef
Type : ElementRef
Decorators :
@ViewChild('contentElement')
frontElementRef
Type : ElementRef
Decorators :
@ViewChild('frontElement')
isCorrect
Type : unknown
Default value : signal<boolean | null>(null)

Whether the selected option is correct (poll variant).

isFlipped
Type : unknown
Default value : signal(false)

Whether the card is currently flipped (showing back).

questionElementRef
Type : ElementRef
Decorators :
@ViewChild('questionElement')
questionId
Type : unknown
Default value : computed(() => `${this.id()}-question`)

Unique identifier for the question element.

selectedOptionIndex
Type : unknown
Default value : signal<number | null>(null)

Index of the selected option (poll variant).

Readonly styleTransform
Type : string
Default value : 'translate3d(0px, 0px, 0px)'
variant
Type : "poll" | "reveal"
Default value : 'reveal'

The variant of the quiz, set by the parent EclQuizComponent.

Accessors

cssClasses
getcssClasses()
tabIndex
gettabIndex()

results matching ""

    No results matching ""