Skip to content
This repository was archived by the owner on Feb 6, 2024. It is now read-only.

Commit 00a05bc

Browse files
feat: modify pager display and add ability to display steps
1 parent 56c8217 commit 00a05bc

File tree

7 files changed

+65
-43
lines changed

7 files changed

+65
-43
lines changed

docs/docs/deck/app-deck-pager/app-deck-pager.md

Lines changed: 11 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -4,16 +4,18 @@
44

55
Also worth to notice that the pager inherits per default the document and deck direction (LTR or RTL for example).
66

7-
- [Show or hide](#app-deck-pager-show-or-hide)
7+
- [Deck](#app-deck-pager-deck)
88
- [Customization](#app-deck-pager-customization)
99

1010
## Show or hide
1111

12-
The show or hide options of the pager are available on the `<deckgo-deck>` element.
12+
To show or hide the pager, a CSS4 variable has to be set on the `<deckgo-deck>` element. Two more options are also available when set on this element.
1313

14-
| Attribute | Type | Default | Description |
15-
| -------------------------- |-----------------|-----------------|-----------------|
16-
| pagerPercentage | boolean | true | Show or hide the progression in percentage inside the pager |
14+
| Attribute | Default | Description |
15+
| -------------------------- |-----------------|-----------------|
16+
| --pager-display | | The display property of the pager. Set to `none` to hide it. |
17+
| --pager-position-left | | The left attribute of the absolute positioning of the pager over the deck |
18+
| --pager-position-right | | The right attribute of the absolute positioning of the pager over the deck |
1719

1820
## Customization
1921

@@ -31,8 +33,9 @@ The following style options are available to style the pager:
3133
| --pager-text-size | 0.5em | |
3234
| --pager-stroke-outer-width | 2.8 | |
3335
| --pager-stroke-inner-width | 1.8 | |
34-
| --pager-position-left | | |
35-
| --pager-position-right | | |
36-
| --pager-display | | To hide the pager |
36+
| --pager-text-percentage-display | hidden | Set to `block` to display a progression with percentage (for example: 35%) |
37+
| --pager-text-slides-display | hidden | Set to `block` to display a progression as slides' count (for example: 2/15) |
38+
39+
Note: of course if you would display both `--pager-text-percentage-display` and `--pager-text-slides-display` it would be a weird display, use just one at once.
3740

3841
[DeckDeckGo]: https://deckdeckgo.com

docs/src/app/pages/docs/deck/app-deck-pager/app-deck-pager.tsx

Lines changed: 22 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -34,25 +34,33 @@ export class AppDeckPager {
3434
<p><a href="https://deckdeckgo.com">DeckDeckGo</a> will per default display a pager in form of a progress circle bar. It&#39;s possible to hide it or to customize the following various style options.</p>
3535
<p>Also worth to notice that the pager inherits per default the document and deck direction (LTR or RTL for example).</p>
3636
<ul>
37-
<li><a href="#app-deck-pager-show-or-hide">Show or hide</a></li>
37+
<li><a href="#app-deck-pager-deck">Deck</a></li>
3838
<li><a href="#app-deck-pager-customization">Customization</a></li>
3939
</ul>
4040
<h2 id="app-deck-pager-show-or-hide">Show or hide</h2>
41-
<p>The show or hide options of the pager are available on the <code>&lt;deckgo-deck&gt;</code> element.</p>
41+
<p>To show or hide the pager, a CSS4 variable has to be set on the <code>&lt;deckgo-deck&gt;</code> element. Two more options are also available when set on this element.</p>
4242
<table>
4343
<thead>
4444
<tr>
4545
<th>Attribute</th>
46-
<th>Type</th>
4746
<th>Default</th>
4847
<th>Description</th>
4948
</tr>
5049
</thead>
5150
<tbody><tr>
52-
<td>pagerPercentage</td>
53-
<td>boolean</td>
54-
<td>true</td>
55-
<td>Show or hide the progression in percentage inside the pager</td>
51+
<td>--pager-display</td>
52+
<td></td>
53+
<td>The display property of the pager. Set to <code>none</code> to hide it.</td>
54+
</tr>
55+
<tr>
56+
<td>--pager-position-left</td>
57+
<td></td>
58+
<td>The left attribute of the absolute positioning of the pager over the deck</td>
59+
</tr>
60+
<tr>
61+
<td>--pager-position-right</td>
62+
<td></td>
63+
<td>The right attribute of the absolute positioning of the pager over the deck</td>
5664
</tr>
5765
</tbody></table>
5866
<h2 id="app-deck-pager-customization">Customization</h2>
@@ -116,21 +124,17 @@ export class AppDeckPager {
116124
<td></td>
117125
</tr>
118126
<tr>
119-
<td>--pager-position-left</td>
120-
<td></td>
121-
<td></td>
122-
</tr>
123-
<tr>
124-
<td>--pager-position-right</td>
125-
<td></td>
126-
<td></td>
127+
<td>--pager-text-percentage-display</td>
128+
<td>hidden</td>
129+
<td>Set to <code>block</code> to display a progression with percentage (for example: 35%)</td>
127130
</tr>
128131
<tr>
129-
<td>--pager-display</td>
130-
<td></td>
131-
<td>To hide the pager</td>
132+
<td>--pager-text-slides-display</td>
133+
<td>hidden</td>
134+
<td>Set to <code>block</code> to display a progression as slides&#39; count (for example: 2/15)</td>
132135
</tr>
133136
</tbody></table>
137+
<p>Note: of course if you would display both <code>--pager-text-percentage-display</code> and <code>--pager-text-slides-display</code> it would be a weird display, use just one at once.</p>
134138
</main>
135139

136140
<app-footer></app-footer>

webcomponents/core/CHANGELOG.md

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,18 @@
1+
<a name="1.0.0-beta.38"></a>
2+
# 1.0.0-beta.38 (2019-06-06)
3+
4+
### Breaking changes
5+
6+
* hide pager progression with a CSS4 variable
7+
8+
### Fix
9+
10+
* don't track slides' swipe if contextmenu is fired
11+
12+
### Features
13+
14+
* new progression text as slides count available
15+
116
<a name="1.0.0-beta.37"></a>
217
# 1.0.0-beta.37 (2019-06-04)
318

webcomponents/core/src/components.d.ts

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,6 @@ export namespace Components {
2323
'isMobile': () => Promise<boolean>;
2424
'keyboard': boolean;
2525
'loadBackground': () => Promise<void>;
26-
'pagerPercentage': boolean;
2726
'slideNext': (slideAnimation?: boolean, emitEvent?: boolean) => Promise<void>;
2827
'slidePrev': (slideAnimation?: boolean, emitEvent?: boolean) => Promise<void>;
2928
'slideTo': (index: number, speed?: number, emitEvent?: boolean) => Promise<void>;
@@ -39,7 +38,6 @@ export namespace Components {
3938
interface DeckgoPager {
4039
'activeIndex': number;
4140
'length': number;
42-
'percentage': boolean;
4341
}
4442
interface DeckgoSlideAuthor {
4543
'afterSwipe': () => Promise<void>;
@@ -280,7 +278,6 @@ declare namespace LocalJSX {
280278
'onSlideToChange'?: (event: CustomEvent<number>) => void;
281279
'onSlideWillChange'?: (event: CustomEvent<number>) => void;
282280
'onSlidesDidLoad'?: (event: CustomEvent<any>) => void;
283-
'pagerPercentage'?: boolean;
284281
}
285282
interface DeckgoGif extends JSXBase.HTMLAttributes<HTMLDeckgoGifElement> {
286283
'alt'?: string;
@@ -291,7 +288,6 @@ declare namespace LocalJSX {
291288
interface DeckgoPager extends JSXBase.HTMLAttributes<HTMLDeckgoPagerElement> {
292289
'activeIndex'?: number;
293290
'length'?: number;
294-
'percentage'?: boolean;
295291
}
296292
interface DeckgoSlideAuthor extends JSXBase.HTMLAttributes<HTMLDeckgoSlideAuthorElement> {
297293
'customActions'?: boolean;

webcomponents/core/src/components/deck/deckdeckgo-deck/deckdeckgo-deck.tsx

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -23,8 +23,6 @@ export class DeckdeckgoDeck {
2323

2424
@Prop() keyboard: boolean = true;
2525

26-
@Prop() pagerPercentage: boolean = true;
27-
2826
@Prop() embedded: boolean = false;
2927

3028
@Prop() cloneBackground: boolean = true;
@@ -190,7 +188,6 @@ export class DeckdeckgoDeck {
190188

191189
@Listen('mousedown', {passive: true})
192190
mousedown($event: MouseEvent) {
193-
console.log('down');
194191
this.start($event);
195192
}
196193

@@ -201,7 +198,6 @@ export class DeckdeckgoDeck {
201198

202199
@Listen('mouseup', {passive: true})
203200
async mouseup($event: MouseEvent) {
204-
console.log('up');
205201
await this.stop($event);
206202
}
207203

@@ -212,7 +208,6 @@ export class DeckdeckgoDeck {
212208

213209
@Listen('mousemove', {passive: true})
214210
async mousemove($event: MouseEvent) {
215-
console.log('move');
216211
await this.move($event);
217212
}
218213

@@ -819,7 +814,7 @@ export class DeckdeckgoDeck {
819814
<slot name="background"></slot>
820815
</div>,
821816
<div class="deckgo-pager">
822-
<deckgo-pager active-index={this.activeIndex} length={this.length} percentage={this.pagerPercentage}></deckgo-pager>
817+
<deckgo-pager active-index={this.activeIndex} length={this.length}></deckgo-pager>
823818
</div>
824819
]
825820
}

webcomponents/core/src/components/pager/deckdeckgo-pager/deckdeckgo-pager.scss

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,11 +27,19 @@
2727
transition: stroke-dasharray 500ms cubic-bezier(0.23, 1, 0.320, 1);
2828
}
2929

30-
.deckgo-pager-percentage {
30+
.deckgo-pager-progression {
3131
fill: var(--pager-text-color, #4c8dff);
3232
font-size: var(--pager-text-size, 0.5em);
3333
text-anchor: middle;
3434
font-weight: 300;
35+
36+
&.deckgo-pager-percentage {
37+
display: var(--pager-text-percentage-display, none);
38+
}
39+
40+
&.deckgo-pager-slides {
41+
display: var(--pager-text-slides-display, none);
42+
}
3543
}
3644

3745
@media print {

webcomponents/core/src/components/pager/deckdeckgo-pager/deckdeckgo-pager.tsx

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -11,21 +11,19 @@ export class DeckdeckgoPager {
1111
@Prop() activeIndex: number;
1212
@Prop() length: number;
1313

14-
@Prop() percentage: boolean = false;
15-
1614
@State()
17-
private progression: number = 0;
15+
private percentageProgression: number = 0;
1816

1917
@Watch('length')
2018
@Watch('activeIndex')
2119
calculateProgression() {
22-
this.progression = this.length > 0 ? Math.round(((this.activeIndex + 1) / this.length) * 100) : 0;
20+
this.percentageProgression = this.length > 0 ? Math.round(((this.activeIndex + 1) / this.length) * 100) : 0;
2321
}
2422

2523
// Nice circular percentage chart from the article of Sergio Pedercini
2624
// https://medium.com/@pppped/how-to-code-a-responsive-circular-percentage-chart-with-svg-and-css-3632f8cd7705
2725
render() {
28-
const ratio: string = '' + this.progression + ', 100';
26+
const ratio: string = '' + this.percentageProgression + ', 100';
2927

3028
return <svg viewBox="0 0 36 36" class="deckgo-pager-circular-chart">
3129
<path class="deckgo-pager-circle-bg"
@@ -44,7 +42,10 @@ export class DeckdeckgoPager {
4442
}
4543

4644
private renderText() {
47-
return this.percentage ? <text x="18" y="20.35" class="deckgo-pager-percentage">{this.progression}%</text> : undefined;
45+
return [
46+
<text x="18" y="20.35" class="deckgo-pager-progression deckgo-pager-percentage">{this.percentageProgression}%</text>,
47+
<text x="18" y="20.35" class="deckgo-pager-progression deckgo-pager-slides">{this.activeIndex + 1}/{this.length}</text>
48+
];
4849
}
4950

5051
}

0 commit comments

Comments
 (0)