amphora-html 6.0.1-dev.0 → 7.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,268 +0,0 @@
1
- 'use strict';
2
-
3
- const _ = require('lodash'),
4
- filename = __filename.split('/').pop().split('.').shift(),
5
- lib = require('./' + filename),
6
- files = require('nymag-fs');
7
-
8
- jest.mock('nymag-fs', () => ({
9
- getFiles: () => []
10
- }));
11
-
12
- describe(_.startCase(filename), () => {
13
- beforeEach(() => {
14
- var diMockData = [
15
- 'blockquote.css',
16
- 'video.css'
17
- ],
18
- vultureMockData = [
19
- 'blockquote.css',
20
- 'blockquote_red.css',
21
- 'blockquote_blue.css',
22
- 'video.css',
23
- 'video_fullbleed.css',
24
- 'video_mobile.css'
25
- ],
26
- defaultMockData = [
27
- 'blockquote.css',
28
- 'blockquote_red.css',
29
- 'pull-quote.css',
30
- 'pull-quote_large.css'
31
- ];
32
-
33
- jest.spyOn(files, 'getFiles').mockImplementation((path) => {
34
- if (path === 'styleguides/di/components') return diMockData;
35
- if (path === 'styleguides/vulture/components') return vultureMockData;
36
- if (path === 'styleguides/_default/components') return defaultMockData;
37
- return [];
38
- });
39
-
40
- // bust memoization cache
41
- lib.getVariations.cache = new Map();
42
- });
43
-
44
- test('get all available component variations', () => {
45
- var expected = {
46
- blockquote: [ 'blockquote_red', 'blockquote_blue' ],
47
- video: [ 'video_fullbleed', 'video_mobile' ],
48
- 'pull-quote': ['pull-quote_large']
49
- };
50
-
51
- expect(lib.getVariations('vulture')).toEqual(expected);
52
- });
53
-
54
- test('gets default variations', () => {
55
- var expected = {
56
- 'pull-quote': [ 'pull-quote_large' ],
57
- blockquote: [ 'blockquote_red' ]
58
- };
59
-
60
- expect(lib.getVariations('_default')).toEqual(expected);
61
- });
62
-
63
- test('gets default variations when passed no styleguide', () => {
64
- var expected = {
65
- 'pull-quote': [ 'pull-quote_large' ],
66
- blockquote: [ 'blockquote_red' ]
67
- };
68
-
69
- expect(lib.getVariations()).toEqual(expected);
70
- });
71
-
72
- test(
73
- 'set default variations for components that have variations but none set',
74
- () => {
75
- var testData = {
76
- main: [
77
- {
78
- _ref: 'www.vulture.com/_components/blockquote/instances/foo@published',
79
- componentVariation: 'blockquote_red'
80
- },
81
- {
82
- _ref: 'www.vulture.com/_components/blockquote/instances/bar@published',
83
- },
84
- {
85
- _ref: 'www.vulture.com/_components/clay-paragraph/instances/cjeq5662h001b3i61rr8fffu1@published',
86
- },
87
- {
88
- _ref: 'www.vulture.com/_components/article-sidebar/instances/foobar@published',
89
- content: [
90
- { _ref: 'www.vulture.com/_components/blockquote/instances/pho@published'}
91
- ]
92
- }
93
- ],
94
- primary: [
95
- {
96
- _ref: 'www.vulture.com/_components/video/instances/foo@published'
97
- },
98
- ]
99
- },
100
- expectedData = {
101
- main: [
102
- {
103
- _ref: 'www.vulture.com/_components/blockquote/instances/foo@published',
104
- componentVariation: 'blockquote_red'
105
- },
106
- {
107
- _ref: 'www.vulture.com/_components/blockquote/instances/bar@published',
108
- componentVariation: 'blockquote'
109
- },
110
- {
111
- _ref: 'www.vulture.com/_components/clay-paragraph/instances/cjeq5662h001b3i61rr8fffu1@published',
112
- componentVariation: 'clay-paragraph'
113
- },
114
- {
115
- _ref: 'www.vulture.com/_components/article-sidebar/instances/foobar@published',
116
- componentVariation: 'article-sidebar',
117
- content: [
118
- {
119
- _ref: 'www.vulture.com/_components/blockquote/instances/pho@published',
120
- componentVariation: 'blockquote'
121
- }
122
- ]
123
- }
124
- ],
125
- primary: [
126
- {
127
- _ref: 'www.vulture.com/_components/video/instances/foo@published',
128
- componentVariation: 'video'
129
- },
130
- ]
131
- },
132
- expectedUsedVariations = [
133
- 'layout',
134
- 'blockquote_red',
135
- 'blockquote',
136
- 'clay-paragraph',
137
- 'article-sidebar',
138
- 'video'
139
- ],
140
- state = {
141
- _layoutRef: 'www.vulture.com/_components/layout/instances/article',
142
- _componentVariations: lib.getVariations('vulture')
143
- };
144
-
145
- lib.setDefaultVariations(
146
- testData,
147
- state
148
- );
149
-
150
- expect(testData).toEqual(expectedData);
151
- expect(state._usedVariations).toEqual(expectedUsedVariations);
152
- }
153
- );
154
-
155
- test(
156
- 'sets default variation if specified variation does not exist',
157
- () => {
158
- let testData = {
159
- main: [
160
- {
161
- _ref: 'domain.com/_components/blockquote/instances/foo',
162
- componentVariation: 'blockquote_red'
163
- }
164
- ]
165
- },
166
- expectedData = {
167
- main: [
168
- {
169
- _ref: 'domain.com/_components/blockquote/instances/foo',
170
- componentVariation: 'blockquote'
171
- }
172
- ]
173
- },
174
- state = {
175
- _layoutRef: 'www.vulture.com/_components/layout/instances/article',
176
- _componentVariations: {}
177
- };
178
-
179
- lib.setDefaultVariations(testData, state);
180
- expect(testData).toEqual(expectedData);
181
- }
182
- );
183
-
184
- test('handles rendering a component and not a page', () => {
185
- let testData = {
186
- content: [{
187
- _ref: 'domain.com/_components/blockquote/instances/foo'
188
- }],
189
- singleCmpt: {
190
- _ref: 'domain.com/_components/foobar/instances/baz'
191
- }
192
- },
193
- expectedData = {
194
- content: [
195
- {
196
- _ref: 'domain.com/_components/blockquote/instances/foo',
197
- componentVariation: 'blockquote'
198
- }
199
- ],
200
- singleCmpt: {
201
- _ref: 'domain.com/_components/foobar/instances/baz',
202
- componentVariation: 'foobar'
203
- }
204
- },
205
- state = {
206
- _self: 'domain.com/_components/foo/instances/bar',
207
- _layoutRef: undefined,
208
- _componentVariations: {}
209
- };
210
-
211
- lib.setDefaultVariations(testData, state);
212
- expect(testData).toEqual(expectedData);
213
- });
214
-
215
- test(
216
- 'do not change data if there are no components in the page data',
217
- () => {
218
- var testData = ['Steve Rogers', 'Tony Stark', 'Natasha Romanov', 'Clint Barton', 'Wanda Maximoff'],
219
- variations = lib.getVariations('vulture'),
220
- state = {
221
- _layoutRef: 'www.vulture.com/_components/layout/instances/article',
222
- _componentVariations: variations
223
- };
224
-
225
- lib.setDefaultVariations(testData, state);
226
- expect(testData).toEqual(testData);
227
- }
228
- );
229
-
230
- test('do not change data if there are no component variations', () => {
231
- var testData = [
232
- {
233
- _ref: 'nymag.com/daily/intelligencer/_components/blockquote/instances/foo@published'
234
- },
235
- {
236
- _ref: 'nymag.com/daily/intelligencer/_components/blockquote/instances/bar@published',
237
- },
238
- {
239
- _ref: 'nymag.com/daily/intelligencer/_components/clay-paragraph/instances/cjeq5662h001b3i61rr8fffu1@published',
240
- }
241
- ],
242
- variations = lib.getVariations('di'),
243
- state = {
244
- _layoutRef: 'nymag.com/daily/intelligencer/_components/layout/instances/article',
245
- _componentVariations: variations
246
- };
247
-
248
- lib.setDefaultVariations(testData, state);
249
- expect(testData).toEqual(testData);
250
- });
251
-
252
- test('handles top level componentVariations (when rendering an individual component with variation', () => {
253
- let _data = {
254
- _ref: 'nymag.com/daily/intelligencer/_components/blockquote/instances/foo@published',
255
- componentVariation: 'blockquote_red',
256
- },
257
- state = {
258
- _self: 'nymag.com/daily/intelligencer/_components/blockquote/instances/foo@published',
259
- _layoutRef: undefined,
260
- _componentVariations: lib.getVariations('di')
261
- };
262
-
263
- lib.setDefaultVariations(_data, state);
264
- expect(state._usedVariations).toEqual([
265
- 'blockquote_red'
266
- ]);
267
- });
268
- });
package/test/setupFile.js DELETED
@@ -1,3 +0,0 @@
1
- 'use strict';
2
-
3
- jest.mock('clay-log');
package/website/README.md DELETED
@@ -1,114 +0,0 @@
1
- You will need to have `Node >= 8.x` and `Yarn >= 1.5`.
2
-
3
- # Run the local server
4
-
5
- 1. Make sure all the dependencies for the website are installed:
6
-
7
- ```sh
8
- $ yarn
9
- ```
10
-
11
- or
12
-
13
- ```sh
14
- $ npm install
15
- ```
16
-
17
- 2. Go to the `website` directory and run your dev server:
18
-
19
- ```sh
20
- $ yarn start
21
- ```
22
-
23
- or
24
-
25
- ```sh
26
- $ npm run start
27
- ```
28
-
29
- ## Directory Structure
30
-
31
- Your project file structure should look something like this
32
-
33
- ```
34
- root-directory
35
- ├── docs
36
- ├── docs.md
37
- website/
38
- ├── README.md
39
- ├── core
40
-    └── Footer.js
41
- ├── i18n
42
-    └── en.json
43
- ├── package.json
44
- ├── pages
45
-    └── en
46
-    └── index.js
47
- ├── sidebars.json
48
- ├── siteConfig.js
49
- └── static
50
- ├── css
51
-   └── custom.css
52
- └── img
53
- ├── favicon
54
- └── logo.svg
55
- ```
56
-
57
- # Versioning the Code
58
-
59
- The first step to begin the process of versioning your documentation is to generate the `versions` script on your website directory with the following command.
60
-
61
- ```sh
62
- yarn examples versions
63
- ```
64
-
65
- or
66
-
67
- ```sh
68
- npm run examples versions
69
- ```
70
-
71
- Then, you proceed to create a version of the docs that you need. In this case, it needs to match the version of your current `package.json`. To do this we will use the following command followed by the version number that you want.
72
-
73
- ```sh
74
- $ yarn version X.X.X
75
- ```
76
-
77
- or
78
-
79
- ```sh
80
- $ npm version X.X.X
81
- ```
82
-
83
- This will create all the files needed to handle the version that you just built, but this will be necessary only in 2 cases:
84
-
85
- 1. If the documentation doesn't have a version set
86
- 2. If there is a major update on the number of the version
87
-
88
- For other cases, we have an active call [update version](https://github.com/clay/amphora-html/blob/master/.github/main.workflow) that will handle the change of the version automatically.
89
-
90
- # Publish the website
91
-
92
- This process is automatically done by an action call [Build and push docs](https://github.com/clay/amphora-html/blob/master/.github/main.workflow) but you can deploy your documentation manually. You just need to run the following commands:
93
-
94
- ```sh
95
- $ yarn build
96
- ```
97
-
98
- or
99
-
100
- ```sh
101
- $ npm run build
102
- ```
103
-
104
- Then, deploy the static files generated. These files will be pushed to the `gh-page` branch.
105
-
106
- ```sh
107
- $ yarn deploy
108
- ```
109
-
110
- or
111
-
112
- ```sh
113
- $ npm run deploy
114
- ```
@@ -1,55 +0,0 @@
1
- /**
2
- * Copyright (c) 2017-present, Facebook, Inc.
3
- *
4
- * This source code is licensed under the MIT license found in the
5
- * LICENSE file in the root directory of this source tree.
6
- */
7
-
8
- const React = require('react');
9
-
10
- class Footer extends React.Component {
11
- docUrl(doc, language) {
12
- const baseUrl = this.props.config.baseUrl;
13
- const docsUrl = this.props.config.docsUrl;
14
- const docsPart = `${docsUrl ? `${docsUrl}/` : ''}`;
15
- const langPart = `${language ? `${language}/` : ''}`;
16
- return `${baseUrl}${docsPart}${langPart}${doc}`;
17
- }
18
-
19
- pageUrl(doc, language) {
20
- const baseUrl = this.props.config.baseUrl;
21
- return baseUrl + (language ? `${language}/` : '') + doc;
22
- }
23
-
24
- render() {
25
- return (
26
- <footer className="nav-footer" id="footer">
27
- <section className="sitemap">
28
- <a href={this.props.config.baseUrl} className="nav-home">
29
- {this.props.config.footerIcon && (
30
- <img
31
- src={this.props.config.baseUrl + this.props.config.footerIcon}
32
- alt={this.props.config.title}
33
- width="66"
34
- height="58"
35
- />
36
- )}
37
- </a>
38
- <div>
39
- <h5>Docs</h5>
40
- <a href={this.docUrl('intro', this.props.language)}>
41
- Introduction
42
- </a>
43
- </div>
44
- <div>
45
- <h5>More</h5>
46
- <a target="_blank" href="https://github.com/clay/amphora-html">GitHub</a>
47
- </div>
48
- </section>
49
- <section className="copyright">{this.props.config.copyright}</section>
50
- </footer>
51
- );
52
- }
53
- }
54
-
55
- module.exports = Footer;
@@ -1,16 +0,0 @@
1
- {
2
- "scripts": {
3
- "examples": "docusaurus-examples",
4
- "start": "docusaurus-start",
5
- "build": "docusaurus-build",
6
- "publish-gh-pages": "docusaurus-publish",
7
- "write-translations": "docusaurus-write-translations",
8
- "version": "docusaurus-version",
9
- "rename-version": "docusaurus-rename-version",
10
- "deploy": "gh-pages -d build/amphora-html"
11
- },
12
- "devDependencies": {
13
- "docusaurus": "^1.8.1",
14
- "gh-pages": "^2.0.1"
15
- }
16
- }
@@ -1,103 +0,0 @@
1
- /**
2
- * Copyright (c) 2017-present, Facebook, Inc.
3
- *
4
- * This source code is licensed under the MIT license found in the
5
- * LICENSE file in the root directory of this source tree.
6
- */
7
-
8
- const React = require('react');
9
-
10
- const CompLibrary = require('../../core/CompLibrary.js');
11
-
12
- const MarkdownBlock = CompLibrary.MarkdownBlock; /* Used to read markdown */
13
- const Container = CompLibrary.Container;
14
- const GridBlock = CompLibrary.GridBlock;
15
-
16
- class HomeSplash extends React.Component {
17
- render() {
18
- const {siteConfig, language = ''} = this.props;
19
- const {baseUrl, docsUrl} = siteConfig;
20
- const docsPart = `${docsUrl ? `${docsUrl}/` : ''}`;
21
- const langPart = `${language ? `${language}/` : ''}`;
22
- const docUrl = doc => `${baseUrl}${docsPart}${langPart}${doc}`;
23
-
24
- const SplashContainer = props => (
25
- <div className="homeContainer">
26
- <div className="homeSplashFade">
27
- <div className="wrapper homeWrapper">{props.children}</div>
28
- </div>
29
- </div>
30
- );
31
-
32
- const Logo = props => (
33
- <div className="projectLogo">
34
- <img src={props.img_src} alt="Project Logo" />
35
- </div>
36
- );
37
-
38
- const ProjectTitle = () => (
39
- <h2 className="projectTitle">
40
- {siteConfig.title}
41
- <small>{siteConfig.tagline}</small>
42
- </h2>
43
- );
44
-
45
- const PromoSection = props => (
46
- <div className="section promoSection">
47
- <div className="promoRow">
48
- <div className="pluginRowBlock">{props.children}</div>
49
- </div>
50
- </div>
51
- );
52
-
53
- const Button = props => (
54
- <div className="pluginWrapper buttonWrapper">
55
- <a className="button" href={props.href} target={props.target}>
56
- {props.children}
57
- </a>
58
- </div>
59
- );
60
-
61
- return (
62
- <SplashContainer>
63
- <div className="inner">
64
- <ProjectTitle siteConfig={siteConfig} />
65
- <PromoSection>
66
- <Button href={docUrl('intro')}>Introduction</Button>
67
- <Button href="https://github.com/clay/amphora-html" target="_blank">View on Github</Button>
68
- </PromoSection>
69
- </div>
70
- </SplashContainer>
71
- );
72
- }
73
- }
74
-
75
- class Index extends React.Component {
76
- render() {
77
- const {config: siteConfig, language = ''} = this.props;
78
- const {baseUrl} = siteConfig;
79
-
80
- const Block = props => (
81
- <Container
82
- padding={['bottom', 'top']}
83
- id={props.id}
84
- background={props.background}>
85
- <GridBlock
86
- align="center"
87
- contents={props.children}
88
- layout={props.layout}
89
- />
90
- </Container>
91
- );
92
-
93
- return (
94
- <div>
95
- <HomeSplash siteConfig={siteConfig} language={language} />
96
- <div className="mainContainer">
97
- </div>
98
- </div>
99
- );
100
- }
101
- }
102
-
103
- module.exports = Index;
@@ -1,92 +0,0 @@
1
- /**
2
- * Copyright (c) 2017-present, Facebook, Inc.
3
- *
4
- * This source code is licensed under the MIT license found in the
5
- * LICENSE file in the root directory of this source tree.
6
- */
7
-
8
- const React = require('react');
9
-
10
- const CompLibrary = require('../../core/CompLibrary');
11
-
12
- const Container = CompLibrary.Container;
13
-
14
- const CWD = process.cwd();
15
-
16
- const versions = require(`${CWD}/versions.json`);
17
-
18
- function Versions(props) {
19
- const {config: siteConfig} = props;
20
- const latestVersion = versions[0];
21
- const repoUrl = "https://github.com/clay/amphora-html";
22
- return (
23
- <div className="docMainWrapper wrapper">
24
- <Container className="mainContainer versionsContainer">
25
- <div className="post">
26
- <header className="postHeader">
27
- <h1>{siteConfig.title} Versions</h1>
28
- </header>
29
- <p>New versions of this project are released every so often.</p>
30
- <h3 id="latest">Current version (Stable)</h3>
31
- <table className="versions">
32
- <tbody>
33
- <tr>
34
- <th>{latestVersion}</th>
35
- <td>
36
- <a href={`${siteConfig.baseUrl}docs/intro`}>Documentation</a>
37
- </td>
38
- <td>
39
- <a href={`https://github.com/clay/amphora-html/releases/tag/v${latestVersion}`} target="_blank">Release Notes</a>
40
- </td>
41
- </tr>
42
- </tbody>
43
- </table>
44
- <p>
45
- This is the version that is configured automatically when you first
46
- install this project.
47
- </p>
48
- <h3 id="rc">Pre-release versions</h3>
49
- <table className="versions">
50
- <tbody>
51
- <tr>
52
- <th>master</th>
53
- <td>
54
- <a href={`${siteConfig.baseUrl}docs/next/intro`}>Documentation</a>
55
- </td>
56
- <td>
57
- <a href="https://github.com/clay/amphora-html/releases" target="_blank">Release Notes</a>
58
- </td>
59
- </tr>
60
- </tbody>
61
- </table>
62
- <p>Other text describing this section.</p>
63
- <h3 id="archive">Past Versions</h3>
64
- <table className="versions">
65
- <tbody>
66
- {versions.map(
67
- version =>
68
- version !== latestVersion && (
69
- <tr>
70
- <th>{version}</th>
71
- <td>
72
- <a href={`${siteConfig.baseUrl}docs/${version}/intro`}>Documentation</a>
73
- </td>
74
- <td>
75
- <a href={`https://github.com/clay/amphora-html/releases/tag/v${version}`}>Release Notes</a>
76
- </td>
77
- </tr>
78
- ),
79
- )}
80
- </tbody>
81
- </table>
82
- <p>
83
- You can find past versions of this project on{' '}
84
- <a href={repoUrl} target="_blank">GitHub</a>.
85
- </p>
86
- </div>
87
- </Container>
88
- </div>
89
- );
90
- }
91
-
92
- module.exports = Versions;
@@ -1,13 +0,0 @@
1
- {
2
- "docs": {
3
- "Introduction": [
4
- "intro"
5
- ],
6
- "Integration": [
7
- "integration"
8
- ],
9
- "Styleguide": [
10
- "style"
11
- ]
12
- }
13
- }