Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add highlight modification #172

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion demo/demos.json
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,8 @@
"demo/pb-grid.html": "Demo"
},
"pb-highlight": {
"demo/pb-highlight.html": "Demo"
"demo/pb-highlight.html": "Demo",
"demo/pb-highlight2.html": "Demo"
},
"pb-i18n": {
"demo/pb-i18n.html": "Demo"
Expand Down
60 changes: 60 additions & 0 deletions demo/pb-highlight2.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
<html>

<head>
<meta charset="utf-8" />
<meta name="viewport" content="width=device-width, minimum-scale=1, initial-scale=1, user-scalable=yes" />

<title>pb-hightlight Demo</title>
<style>
pb-page {
display: flex;
justify-content: space-between;
}
body {
--pb-highlight-background-image: repeating-linear-gradient(
315deg,
mark,
mark 5px,
#F9E976 5px,
#F9E976 10px
);
}
</style>
<!--scripts-->
<script type="module" src="../node_modules/@teipublisher/pb-components/src/pb-page.js"></script>
<script type="module" src="../src/pb-highlight.js"></script>
<!--/scripts-->
</head>

<body>

<h1>Highlight with a gradient background-image</h1>

<pb-page locales="../i18n/{{ns}}/{{lng}}.json">
<div>
<p>
<pb-highlight key="s1" highlight-self="highlight-self">Lorem ipsum dolor sit amet, consetetur
sadipscing elitr, sed diam nonumy eirmod tempor invidunt ut labore et
dolore magna aliquyam erat, sed diam voluptua.</pb-highlight>
<pb-highlight key="s2">At vero eos et accusam et justo duo dolores et ea rebum.</pb-highlight>
<pb-highlight key="s3">Stet clita kasd gubergren, no sea takimata sanctus est Lorem ipsum dolor
sit amet.</pb-highlight>
</p>
</div>
<div>
<p>
<pb-highlight key="s1">Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy
eirmod tempor invidunt ut labore et
dolore magna aliquyam erat, sed diam voluptua.</pb-highlight>
<pb-highlight key="s2">At vero eos et accusam et justo duo dolores et ea rebum.</pb-highlight>
<pb-highlight key="s3">Stet clita kasd gubergren, no sea takimata sanctus est Lorem ipsum dolor
sit amet.</pb-highlight>
</p>
</div>
</pb-page>



</body>

</html>
5 changes: 3 additions & 2 deletions src/pb-highlight.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,8 @@ import { pbMixin } from './pb-mixin';
* @fires pb-highlight-on - Fires highlight event with a key passed to which other pb-highlight elements with the same key will react
* @fires pb-highlight-off - When received, triggers removal of a highlight that might have been on for this element before
* @fires pb-highlight-on - When received, switches the highlight on if the same key was received as the current element has
* @cssprop --pb-highlight-color - Background color to highlight an element
* @cssprop [--pb-highlight-color=#F9E976]- Background color to highlight an element
* @cssprop --pb-highlight-background-image - Background-image to highlight an element with a gradient (e.g. stripes with repeating-linear-gradient). Will override --pb-highlight-color.
*/
export class PbHighlight extends pbMixin(LitElement) {
static get properties() {
Expand Down Expand Up @@ -121,7 +122,7 @@ export class PbHighlight extends pbMixin(LitElement) {
animation-duration: 500ms;
animation-iteration-count: 1;
animation-timing-function: ease-in;

background-image: var(--pb-highlight-background-image);
}

.highlight-off {
Expand Down
Loading