Skip to content

Commit

Permalink
✨ [bento][amp-date-countdown] Change attribute name of count-up (#32201)
Browse files Browse the repository at this point in the history
* Change attribute name of count-up

* Add doc updates for date-countdown

* Add quotes to count up in docs

* Update extensions/amp-date-countdown/amp-date-countdown.md

Co-authored-by: CrystalOnScript <crystallambert@google.com>

Co-authored-by: CrystalOnScript <crystallambert@google.com>
  • Loading branch information
krdwan and CrystalOnScript committed Jan 27, 2021
1 parent fb0d33c commit a497941
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 9 deletions.
2 changes: 1 addition & 1 deletion extensions/amp-date-countdown/1.0/amp-date-countdown.js
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,7 @@ AmpDateCountdown['props'] = {
'whenEnded': {attr: 'when-ended', type: 'string'},
'locale': {attr: 'locale', type: 'string'},
'biggestUnit': {attr: 'biggest-unit', type: 'string'},
'countUp': {attr: 'data-count-up', type: 'boolean'},
'countUp': {attr: 'count-up', type: 'boolean'},
};

/**
Expand Down
12 changes: 6 additions & 6 deletions extensions/amp-date-countdown/1.0/storybook/Basic.amp.js
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ export const Default = () => {
BIGGEST_UNIT_CONFIGURATIONS,
BIGGEST_UNIT_CONFIGURATIONS[0]
);
const countUp = boolean('data-count-up', false);
const countUp = boolean('count-up', false);

return (
<amp-date-countdown
Expand All @@ -113,7 +113,7 @@ export const Default = () => {
locale={locale}
when-ended={whenEnded}
biggest-unit={biggestUnit}
data-count-up={countUp}
count-up={countUp}
layout="fixed-height"
height="100"
>
Expand Down Expand Up @@ -166,7 +166,7 @@ export const DefaultRenderer = () => {
BIGGEST_UNIT_CONFIGURATIONS,
BIGGEST_UNIT_CONFIGURATIONS[0]
);
const countUp = boolean('data-count-up', false);
const countUp = boolean('count-up', false);

return (
<amp-date-countdown
Expand All @@ -180,7 +180,7 @@ export const DefaultRenderer = () => {
locale={locale}
when-ended={whenEnded}
biggest-unit={biggestUnit}
data-count-up={countUp}
count-up={countUp}
layout="fixed-height"
height="100"
></amp-date-countdown>
Expand Down Expand Up @@ -222,7 +222,7 @@ export const ExternalTemplate = () => {
BIGGEST_UNIT_CONFIGURATIONS,
BIGGEST_UNIT_CONFIGURATIONS[0]
);
const countUp = boolean('data-count-up', false);
const countUp = boolean('count-up', false);

return (
<div>
Expand Down Expand Up @@ -251,7 +251,7 @@ export const ExternalTemplate = () => {
locale={locale}
when-ended={whenEnded}
biggest-unit={biggestUnit}
data-count-up={countUp}
count-up={countUp}
template={template}
layout="fixed-height"
height="100"
Expand Down
8 changes: 6 additions & 2 deletions extensions/amp-date-countdown/amp-date-countdown.md
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ This table provides examples of formatted values specified in a Mustache templat

### Migrating from 0.1

The experimental `1.0` version of `amp-date-countdown` does not support the `data-count-up` attribute. This means the `1.0` component is unable to count in the opposite direction.
The experimental `1.0` version of `amp-date-countdown` uses the attribute name `count-up` instead of `data-count-up` as in `0.1` to support the "count up" feature. See the `count-up` section under `Attributes` below for more details.

## Attributes

Expand Down Expand Up @@ -169,10 +169,14 @@ on the specified `biggest-unit` value. For example, assume there are `50 days 10
- Supported values: `days`, `hours`, `minutes`, `seconds`
- Default: `days`

### data-count-up (optional)
### count-up (optional)

Include this attribute to reverse the direction of the countdown to count up instead. This is useful to display the time elapsed since a target date in the past. To continue the countdown when the target date is in the past, be sure to include the `when-ended` attribute with the `continue` value. If the target date is in the future, `amp-date-countdown` will display a decrementing (toward 0) negative value.

[tip type="important"]
Please note that the attribute name is different than `0.1` which uses the `data-count-up` attribute to toggle this feature. The behavior of the feature is otherwise identical to `0.1`.
[/tip]

## Events

The `amp-date-countdown` component exposes the following event that you can use
Expand Down

0 comments on commit a497941

Please sign in to comment.