-
-
Notifications
You must be signed in to change notification settings - Fork 67
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Implement CSS variables composable * Add rookie tests * Update documentation * Fix test typo * Update observer options * Fix mock mistakes * Fix copy-paste error * Bound `get` and `set`'s elements * Update MutationObserver options
- Loading branch information
Showing
11 changed files
with
1,046 additions
and
280 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,78 @@ | ||
<template> | ||
<div> | ||
<div> | ||
<label for="foreground-value" | ||
>Override the value for <code>--color-foreground</code>:</label | ||
> | ||
<input | ||
type="text" | ||
id="foreground-value" | ||
@input="set('color-foreground', $event.target.value)" | ||
:model="foreground" | ||
/> | ||
</div> | ||
|
||
<div class="text" style="color: var(--color-foreground)"> | ||
<span v-if="listening"> | ||
I am a text with the following color: | ||
</span> | ||
<span v-else> | ||
My color will be updated but not my label: | ||
</span> | ||
{{ foreground }} | ||
</div> | ||
|
||
<div> | ||
<button type="button" @click="stop()" :disabled="!listening"> | ||
Stop listening | ||
</button> | ||
<button type="button" @click="resume()" :disabled="listening"> | ||
Resume listening | ||
</button> | ||
<button | ||
type="button" | ||
@click="foreground = get('color-foreground')" | ||
:disabled="listening" | ||
> | ||
Manual label update | ||
</button> | ||
</div> | ||
</div> | ||
</template> | ||
|
||
<script> | ||
import { useCssVariables } from "../../../packages/web/dist/web.cjs.js"; | ||
import { ref } from "@vue/composition-api"; | ||
export default { | ||
name: "css-variables-example", | ||
setup() { | ||
const { stop, resume, get, set, listening, foreground } = useCssVariables({ | ||
foreground: "color-foreground" | ||
}); | ||
set("color-foreground", "red"); | ||
return { | ||
listening, | ||
stop, | ||
resume, | ||
get, | ||
set, | ||
listening, | ||
foreground, | ||
document | ||
}; | ||
} | ||
}; | ||
</script> | ||
|
||
<style scoped> | ||
div > div { | ||
margin-top: 15px; | ||
} | ||
.text { | ||
margin: 15px 0; | ||
} | ||
</style> |
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
Oops, something went wrong.