Skip to content

Commit 77ecf70

Browse files
authored
Add stories for buttons (subscriptions-project#2131)
* Add stories for buttons * Self referential * Add comments
1 parent 359669d commit 77ecf70

File tree

3 files changed

+120
-1
lines changed

3 files changed

+120
-1
lines changed

.storybook/main.js

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,5 +5,10 @@ module.exports = {
55
],
66
'addons': ['@storybook/addon-links', '@storybook/addon-essentials'],
77
'framework': '@storybook/html',
8-
'staticDirs': ['../src/stories/static'],
8+
'staticDirs': [
9+
// HTML
10+
'../src/stories/static',
11+
// CSS
12+
'../assets',
13+
],
914
};
Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
1+
/**
2+
* Copyright 2022 The Subscribe with Google Authors. All Rights Reserved.
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* http://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS-IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*/
16+
17+
import {ButtonApi} from '../runtime/button-api';
18+
19+
const buttonApi = new ButtonApi(null, new Promise(() => {}));
20+
21+
export default {
22+
title: 'Contribute button',
23+
};
24+
25+
export const Enabled = (args) => {
26+
// Add button CSS.
27+
const cssHtml = `<link rel="stylesheet" type="text/css" href="/swg-button.css"></link>`;
28+
self.document.body.insertAdjacentHTML('beforeend', cssHtml);
29+
30+
// Render button.
31+
const buttonEl = self.document.createElement('div');
32+
buttonApi.attachContributeButton(buttonEl, {
33+
enable: true,
34+
lang: args['Language'],
35+
});
36+
return buttonEl;
37+
};
38+
Enabled.args = {
39+
'Language': 'en',
40+
};
41+
42+
export const Disabled = (args) => {
43+
// Add button CSS.
44+
const cssHtml = `<link rel="stylesheet" type="text/css" href="/swg-button.css"></link>`;
45+
self.document.body.insertAdjacentHTML('beforeend', cssHtml);
46+
47+
// Render button.
48+
const buttonEl = self.document.createElement('div');
49+
buttonApi.attachContributeButton(buttonEl, {
50+
enable: false,
51+
lang: args['Language'],
52+
});
53+
return buttonEl;
54+
};
55+
Disabled.args = {
56+
'Language': 'en',
57+
};
Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
1+
/**
2+
* Copyright 2022 The Subscribe with Google Authors. All Rights Reserved.
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* http://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS-IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*/
16+
17+
import {ButtonApi} from '../runtime/button-api';
18+
19+
const buttonApi = new ButtonApi(null, new Promise(() => {}));
20+
21+
export default {
22+
title: 'Subscribe button',
23+
};
24+
25+
export const Enabled = (args) => {
26+
// Add button CSS.
27+
const cssHtml = `<link rel="stylesheet" type="text/css" href="/swg-button.css"></link>`;
28+
self.document.body.insertAdjacentHTML('beforeend', cssHtml);
29+
30+
// Render button.
31+
const buttonEl = self.document.createElement('div');
32+
buttonApi.attachSubscribeButton(buttonEl, {
33+
enable: true,
34+
lang: args['Language'],
35+
});
36+
return buttonEl;
37+
};
38+
Enabled.args = {
39+
'Language': 'en',
40+
};
41+
42+
export const Disabled = (args) => {
43+
// Add button CSS.
44+
const cssHtml = `<link rel="stylesheet" type="text/css" href="/swg-button.css"></link>`;
45+
self.document.body.insertAdjacentHTML('beforeend', cssHtml);
46+
47+
// Render button.
48+
const buttonEl = self.document.createElement('div');
49+
buttonApi.attachSubscribeButton(buttonEl, {
50+
enable: false,
51+
lang: args['Language'],
52+
});
53+
return buttonEl;
54+
};
55+
Disabled.args = {
56+
'Language': 'en',
57+
};

0 commit comments

Comments
 (0)