Skip to content

Commit 6d7b024

Browse files
committed
define a CSS class from the shacl form
This allow to give a particular CSS class to a specific element of the form by defining a new cssClass in the shacl file.
1 parent d2adf99 commit 6d7b024

File tree

2 files changed

+4
-0
lines changed

2 files changed

+4
-0
lines changed

src/property-template.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ import { findLabel, removePrefixes } from './util'
66

77
const mappers: Record<string, (template: ShaclPropertyTemplate, term: Term) => void> = {
88
[`${PREFIX_SHACL}name`]: (template, term) => { const literal = term as Literal; if (!template.name || literal.language === template.config.attributes.language) { template.name = literal } },
9+
[`${PREFIX_SHACL}cssClass`]: (template, term) => { template.cssClass = term.value },
910
[`${PREFIX_SHACL}description`]: (template, term) => { const literal = term as Literal; if (!template.description || literal.language === template.config.attributes.language) { template.description = literal } },
1011
[`${PREFIX_SHACL}path`]: (template, term) => { template.path = term.value },
1112
[`${PREFIX_SHACL}node`]: (template, term) => { template.node = term as NamedNode },
@@ -50,6 +51,7 @@ export class ShaclPropertyTemplate {
5051
label = ''
5152
nodeId: NamedNode | BlankNode
5253
name: Literal | undefined
54+
cssClass: string | undefined
5355
description: Literal | undefined
5456
path: string | undefined
5557
node: NamedNode | undefined

src/property.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,8 @@ export class ShaclProperty extends HTMLElement {
2828
this.addButton.innerText = this.template.label
2929
this.addButton.title = 'Add ' + this.template.label
3030
this.addButton.classList.add('control-button', 'add-button')
31+
if (this.template.cssClass)
32+
this.addButton.classList.add(this.template.cssClass);
3133
this.addButton.addEventListener('click', _ => {
3234
const instance = this.addPropertyInstance()
3335
instance.classList.add('fadeIn')

0 commit comments

Comments
 (0)