Skip to content

Commit 2e19e32

Browse files
author
castastrophe
committed
: Take a stab at documentation
1 parent 00f030f commit 2e19e32

File tree

2 files changed

+39
-0
lines changed

2 files changed

+39
-0
lines changed

elements/pfelement/README.md

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -125,6 +125,44 @@ If a theme value is defined at any point of this flow, an `on` attribute will be
125125

126126
The `context_update` function will use much the same logic except it updates the theme context for the component calling the function and triggers an update for all of it's pfelement children.
127127

128+
### Log
129+
130+
Prints a message to the console log in a standardized format when debugging is turned on: `[pfe-band]: This is my console message.`. To invoke this inside an element, you can add `this.log("This is my console message");` to your JS file.
131+
132+
### Emit event
133+
134+
This allows you to dispatch an event in a standardized way. The function accepts the name of the event and an object containing details about that event. That object supports the following configuration:
135+
136+
| Event setting | Default value |
137+
| --- | --- |
138+
| bubbles | true |
139+
| cancelable | true |
140+
| composed | false |
141+
| detail | {} |
142+
143+
144+
Elements should contain an events object which lists all the event names:
145+
146+
```
147+
static get events() {
148+
return {
149+
change: `${this.tag}:change`
150+
};
151+
}
152+
```
153+
154+
And then reference that object in the following way to invoke those events:
155+
156+
```
157+
this.emitEvent(
158+
PfeAccordion.events.change, {
159+
detail: {
160+
expanded: !this.expanded
161+
}
162+
}
163+
);
164+
```
165+
128166
## Test
129167

130168
npm run test

elements/pfelement/src/pfelement.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -357,6 +357,7 @@ class PFElement extends HTMLElement {
357357
this[name] = value;
358358
}
359359

360+
// @TODO This is a duplicate function to cssVariable above, combine them
360361
static var(name, element = document.body) {
361362
return window
362363
.getComputedStyle(element)

0 commit comments

Comments
 (0)