@data-visuals/create 7.2.0 → 7.3.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.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@data-visuals/create",
3
- "version": "7.2.0",
3
+ "version": "7.3.0",
4
4
  "description": "Create graphics and features the Data Visuals way.",
5
5
  "scripts": {
6
6
  "build:docs": "doctoc README.md --github",
@@ -17,7 +17,7 @@
17
17
  "workspace:push": "node ./utils/deployment/push-workspace.js"
18
18
  },
19
19
  "devDependencies": {
20
- "@babel/core": "^7.0.0",
20
+ "@babel/core": "^7.17.8",
21
21
  "@babel/plugin-proposal-class-properties": "^7.1.0",
22
22
  "@babel/plugin-syntax-dynamic-import": "^7.0.0",
23
23
  "@babel/plugin-transform-react-jsx": "^7.0.0",
@@ -28,7 +28,7 @@
28
28
  "ansi-colors": "^3.2.3",
29
29
  "archieml": "^0.4.1",
30
30
  "assets-webpack-plugin": "^6.1.2",
31
- "autoprefixer": "^9.0.2",
31
+ "autoprefixer": "^10.4.2",
32
32
  "aws-sdk": "^2.372.0",
33
33
  "babel-eslint": "^10.0.1",
34
34
  "babel-loader": "^8.0.0",
@@ -50,7 +50,7 @@
50
50
  "fast-glob": "^2.2.2",
51
51
  "fs-extra": "^7.0.0",
52
52
  "glob-watcher": "^5.0.3",
53
- "googleapis": "^83.0.0",
53
+ "googleapis": "^99.0.0",
54
54
  "html-minifier": "^3.5.21",
55
55
  "imagemin": "^7.0.0",
56
56
  "imagemin-gifsicle": "^7.0.0",
@@ -60,7 +60,7 @@
60
60
  "journalize": "^2.1.0",
61
61
  "mime-types": "^2.1.17",
62
62
  "nunjucks": "^3.0.1",
63
- "postcss": "^7.0.2",
63
+ "postcss": "^8.4.12",
64
64
  "postcss-flexbugs-fixes": "^4.1.0",
65
65
  "prettier": "^1.12.1",
66
66
  "puppeteer": "^5.5.0",
@@ -1,9 +1,9 @@
1
1
  {% import 'macros/processors.html' as processors %}
2
2
 
3
- {% macro prose(content, context, data) %}
3
+ {% macro prose(content, context, data, type) %}
4
4
  {% for item in content %}
5
5
  {% if processors[item.type] %}
6
- {{ processors[item.type](item.value, context, data) }}
6
+ {{ processors[item.type](item.value, context, data, type) }}
7
7
  {% else %}
8
8
  {{ processors['raw'](item.value, context, data) }}
9
9
  {% endif %}
@@ -35,31 +35,4 @@ ${colors.blue.underline(mainPath)} (This has been copied to your clipboard.)
35
35
  Did you run ${colors.yellow(
36
36
  `npm run data:fetch`
37
37
  )} before deploying to get the latest data?`);
38
-
39
- if (projectType === 'feature') {
40
- console.log(`
41
- If you are deploying a feature, check Facebook/Twitter/other social platforms to make sure the
42
- share image shows up.`);
43
- }
44
-
45
- if (projectType === 'graphic') {
46
- console.log(`
47
- If you are deploying a graphic in a CMS story, there are a few steps. First,
48
- add this in the Content section of the Raw Plugin:
49
- ${colors.yellow(
50
- `<div class="dv201808-graphic dv201808-graphic--centered dv201808-graphic--centered-narrow" data-frame-src="${mainPath}" data-frame-sandbox="allow-scripts allow-same-origin allow-top-navigation-by-user-activation allow-top-navigation"></div>`
51
- )}`);
52
-
53
- console.log(`
54
- Next, add the style code snippet found in ${colors.yellow(
55
- 'app/styles/raw-plugin-styles.html'
56
- )} to the CSS content section of the Raw Plugin`);
57
-
58
- console.log(`
59
- Then, add this line to the JavaScript content section of the Raw Plugin:
60
- ${colors.yellow(
61
- '<script src="https://cdn.texastribune.org/lib/@newswire/frames@0.3.1/index.umd.js"></script>'
62
- )}
63
- ${colors.yellow('<script>newswireFrames.autoInitFrames();</script>')}`);
64
- }
65
38
  });
@@ -0,0 +1,31 @@
1
+ /* eslint-disable no-unused-vars */
2
+ import * as d3 from 'd3';
3
+ import createBase from '../utils/d3-base';
4
+
5
+ // a reference to the default graphic container, change if needed
6
+ const container = d3.select('#graphic');
7
+
8
+ // a helper function to clear the container of its contents
9
+ const clearContainer = () => container.html('');
10
+
11
+ // a helper function to grab the container's width
12
+ const getFrameWidth = () => container.node().offsetWidth;
13
+
14
+ // import data by getting the window variable, OR by importing the filepath
15
+ // let data = window.DATA;
16
+ // import data from '../../../data/data.json';
17
+ // import data from 'Data/data.json';
18
+
19
+ /**
20
+ * This function is called to render a graphic, using d3 or a library of your choice.
21
+ *
22
+ * @return {void}
23
+ */
24
+ export default function renderGraphic() {
25
+ // pass the recalculated frameWidth to parts of your chart (like an axis) that change with resize!
26
+ clearContainer();
27
+ const frameWidth = getFrameWidth();
28
+ //
29
+ // rest of your code goes here
30
+ // use createBase() to create the base of an d3 chart
31
+ }
@@ -0,0 +1,7 @@
1
+ import { frameLoader } from '../embeds/frames';
2
+ import renderGraphic from './graphic-embed';
3
+
4
+ // included in index.html by default
5
+ // initiates frame so your graphic is wrapped in an AMP-compatible iframe
6
+ // renderGraphic() renders a coded graphic on load and on resize
7
+ frameLoader(renderGraphic);
@@ -22,8 +22,9 @@
22
22
  {% if graphicSource %}
23
23
  <meta name="tt-graphic-source" content="{{ graphicSource }}" />
24
24
  {% endif %}
25
-
26
- <meta name="tt-graphic-credit" content="{{ graphicCredit or 'Texas Tribune Staff'}}" />
25
+ {% if graphicCredit %}
26
+ <meta name="tt-graphic-credit" content="{{ graphicCredit }}" />
27
+ {% endif %}
27
28
  <meta name="tt-graphic-tags" content="{{ graphicTags or ['subject-politics'] }}" />
28
29
 
29
30
  <link rel="dns-prefetch" href="https://www.google-analytics.com">
@@ -1,9 +1,9 @@
1
1
  {# Template for any scripted graphics, i.e. D3 charts #}
2
- {% extends 'base-graphic.html' %}
2
+ {% extends 'base-embed.html' %}
3
3
  {% from 'macros/prose.html' import prose %}
4
4
 
5
5
  {# set pack that provides JS #}
6
- {% set jsPackName = 'main' %}
6
+ {% set jsPackName = 'main-embed' %}
7
7
 
8
8
  {# data.text --> data/text.json #}
9
9
  {% set context = data.text %}
@@ -23,16 +23,16 @@
23
23
  {# data-title is used to grab the title in the CMS #}
24
24
  <h1 class="graphic-title" data-title>{{ context.headline | widont }}</h1>
25
25
  {# data-caption is used to grab the caption in the CMS #}
26
- <span data-caption>{{ prose(context.graphic_prose, context, graphicData) }}</span>
26
+ <span data-caption>{{ prose(context.embed_prose, context, graphicData, 'embed') }}</span>
27
27
 
28
28
  {# container that JS is attached to #}
29
29
  <div id="graphic" class="graphic"></div>
30
30
 
31
31
  {# data-source, data-credit, and data-note are also used in the CMS #}
32
32
  <ul class="graphic-footer">
33
- {% if context.note %}<li data-note>Note: {{ context.note }}</li>{% endif %}
34
- {% if context.source %}<li data-source>Source: {{ context.source }}</li>{% endif %}
35
- {% if context.credit %}<li data-credit>Credit: {{ context.credit }}</li>{% endif %}
33
+ {% if context.embed_note %}<li data-note>Note: {{ context.embed_note }}</li>{% endif %}
34
+ {% if context.embed_source %}<li data-source>Source: {{ context.embed_source }}</li>{% endif %}
35
+ {% if context.embed_credit %}<li data-credit>Credit: {{ context.embed_credit }}</li>{% endif %}
36
36
  </ul>
37
37
  </div>
38
38
  {% endblock content %}
@@ -4,8 +4,12 @@
4
4
  {{ value | renderStringWithNunjucks(data) }}
5
5
  {% endmacro %}
6
6
 
7
- {% macro text(value, context, data) %}
8
- <p class="copy">{{ value | renderStringWithNunjucks(data) }}</p>
7
+ {% macro text(value, context, data, type) %}
8
+ {% if type == 'embed' %}
9
+ <p class="graphic-prose">{{ value | renderStringWithNunjucks(data) }}</p>
10
+ {% else %}
11
+ <p class="copy">{{ value | renderStringWithNunjucks(data) }}</p>
12
+ {% endif %}
9
13
  {% endmacro %}
10
14
 
11
15
  {% macro list(value) %}
@@ -22,8 +22,9 @@
22
22
  {% if graphicSource %}
23
23
  <meta name="tt-graphic-source" content="{{ graphicSource }}" />
24
24
  {% endif %}
25
-
26
- <meta name="tt-graphic-credit" content="{{ graphicCredit or 'Texas Tribune Staff'}}" />
25
+ {% if graphicCredit %}
26
+ <meta name="tt-graphic-credit" content="{{ graphicCredit }}" />
27
+ {% endif %}
27
28
  <meta name="tt-graphic-tags" content="{{ graphicTags or ['subject-politics'] }}" />
28
29
 
29
30
  <link rel="dns-prefetch" href="https://www.google-analytics.com">