Skip to content

Commit

Permalink
many things
Browse files Browse the repository at this point in the history
  • Loading branch information
hobbes7878 committed Apr 15, 2021
1 parent 671bb9f commit 1a3b8b7
Show file tree
Hide file tree
Showing 21 changed files with 358 additions and 281 deletions.
1 change: 1 addition & 0 deletions .npmrc
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
engine-strict=true
4 changes: 3 additions & 1 deletion google.json
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
{
"docs": {},
"docs": {
"locales/en/content.json": "1D-dlkNwrDYD_puaYICD02NOO8qtQij5MG-FNz9aKsN0"
},
"sheets": {}
}
3 changes: 1 addition & 2 deletions jsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,7 @@
"$utils/*": ["src/utils/*"],
"$pkg": ["package.json"],
"$imgs": ["src/statics/images/manifest.json"],
"$locales/*": ["locales/*"],
"@reuters-graphics/svelte-page-components": ["src/FutureComponentLib/index.js"]
"$locales/*": ["locales/*"]
}
},
"include": ["src/**/*.js", "src/**/*.svelte"]
Expand Down
9 changes: 1 addition & 8 deletions locales/en/content.json
Original file line number Diff line number Diff line change
@@ -1,8 +1 @@
{
"SeoTitle": "Testing",
"SeoDescription": "Testing",
"title": "My page",
"chartTitle": "Congess",
"chartChatter": "Bacon ipsum dolor amet salami bresaola venison, boudin leberkas frankfurter pastrami.",
"story": "English Bacon ipsum dolor amet salami bresaola venison, boudin leberkas frankfurter pastrami. Beef buffalo strip steak boudin. Kevin tenderloin leberkas jowl, strip steak ball tip swine alcatra bacon turkey corned beef chuck brisket chicken tail.\n\nTenderloin cow kevin doner biltong burgdoggen short ribs. Capicola bresaola pork loin, flank spare ribs turducken chuck ham hock prosciutto fatback short ribs rump. Sirloin bresaola pastrami, swine porchetta ham hock short loin frankfurter ham kielbasa tail cow spare ribs cupim."
}
{"SEOTitle":"My page title for Google","SEODescription":"My page description for Google","ShareTitle":"My page title for Twitter","ShareDescription":"My page description for Twitter","Hed":"Reuters Graphics Interactive","Dek":"The beginning of a beautiful page","Kicker":"Global News","blocks":[{"Type":"text","Text":"Pig short ribs jerky, meatloaf turducken ribeye strip steak bacon pastrami tail pancetta chicken. Meatloaf ham hock tail picanha, meatball boudin pancetta capicola chislic kielbasa.\n\n#### This is a subhead\n\n“Rump salami spare ribs jowl corned beef picanha meatloaf bresaola, porchetta jerky ham hock venison ground round alcatra.” Picanha pig chuck pork meatloaf pork loin kevin t-bone leberkas turducken cupim meatball andouille."},{"Type":"photo","AltText":"describe what is happening in the image (for people using screenreaders)","Caption":"add a caption and source information (for all readers)"},{"Type":"text","Text":"Jerky venison flank, landjaeger pork chop capicola turkey. Spare ribs chicken venison, cupim tenderloin porchetta pig andouille ground round.\n\nGround round porchetta boudin drumstick venison beef ribs sausage pig kielbasa short loin. Kevin tenderloin tongue t-bone jerky, chicken ham. Pork chislic short loin burgdoggen pork chop capicola flank pancetta. Pig ground round turducken, rump tail spare ribs kielbasa frankfurter ribeye hamburger."},{"Type":"graphic","Title":"Pig ground round turducken","Chatter":"Pork chislic short loin burgdoggen pork chop capicola flank pancetta."},{"Type":"text","Text":"Jerky venison flank, landjaeger pork chop capicola turkey. Spare ribs chicken venison, cupim tenderloin porchetta pig andouille ground round.\n\nGround round porchetta boudin drumstick venison beef ribs sausage pig kielbasa short loin. Kevin tenderloin tongue t-bone jerky, chicken ham. Pork chislic short loin burgdoggen pork chop capicola flank pancetta. Pig ground round turducken, rump tail spare ribs kielbasa frankfurter ribeye hamburger."}],"EndNotes":"##### Note\nData is current as of today.\n\n##### Sources\nData, Inc.\n\n##### Edited by\n<Editor>, <Copyeditor>"}
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
"@reuters-graphics/graphics-bin": "^0.0.8",
"@reuters-graphics/graphics-kit-publisher": "^0.0.4",
"@rollup/plugin-dsv": "^2.0.1",
"@sveltejs/kit": "next",
"@sveltejs/kit": "^1.0.0-next.75",
"autoprefixer": "^10.2.5",
"eslint": "^7.23.0",
"eslint-plugin-svelte3": "^3.1.0",
Expand All @@ -36,7 +36,7 @@
"sass": "^1.0.0",
"svelte": "^3.29.0",
"svelte-preprocess": "^4.0.0",
"vite": "^2.1.5"
"vite": "^2.1.0"
},
"engines": {
"node": ">= 14.16.0"
Expand Down
11 changes: 9 additions & 2 deletions pages/embed-previewer/index.svelte
Original file line number Diff line number Diff line change
@@ -1,8 +1,15 @@
<script>
import pages from '@svelte-kit-pages';
import { Framer } from '@reuters-graphics/svelte-page-components';
import { Framer } from 'reuters-components';
const embeds = pages.filter(p => /^\/embeds\//.test(p));
</script>

<Framer {embeds} />
<Framer {embeds} />

<style lang='scss'>
:global(body) {
padding-bottom: 60px;
background-color: #fafafa;
}
</style>
23 changes: 16 additions & 7 deletions pages/embeds/en/chart.svelte
Original file line number Diff line number Diff line change
@@ -1,12 +1,21 @@
<script>
import Chart from '$lib/Chart.svelte';
import { PymChild } from '@reuters-graphics/svelte-page-components';
import '$lib/translations';
import { init } from 'svelte-i18n';
init({ initialLocale: 'en' });
import { PymChild } from 'reuters-components';
import content from '$locales/en/content.json';
</script>


<article>
{#each content.blocks as block}
{#if block.Type === 'graphic'}
<Chart title={block.Title} chatter={block.Chatter} />
{/if}
{/each}
</article>
<PymChild />
<article class='container-fluid'>
<Chart />
</article>

<style lang="scss">
:global {
@import "@reuters-graphics/style-theme-eisbaer/scss/main";
}
</style>
26 changes: 26 additions & 0 deletions pages/embeds/en/page.svelte
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
<script>
import { SEO } from 'reuters-components';
import Page from '$lib/Page.svelte';
import content from '$locales/en/content.json';
import { PymChild } from 'reuters-components';
</script>

<SEO
seoTitle={content.SEOTitle}
seoDescription={content.SEODescription}
shareTitle={content.ShareTitle}
shareDescription={content.ShareDescription}
shareImgPath='images/shark.jpg'
lang='en'
/>

<Page />

<PymChild/>

<style lang="scss">
:global {
@import "@reuters-graphics/style-theme-eisbaer/scss/main";
}
</style>

16 changes: 6 additions & 10 deletions pages/index.svelte
Original file line number Diff line number Diff line change
@@ -1,18 +1,14 @@
<script>
import { SEO, Sharer, Referrals, Nav, Footer, EmbedPreviewerLink } from 'reuters-components';
import Page from '$lib/Page.svelte';
import '$lib/translations';
import { SEO, Sharer, Referrals, Nav, Footer, EmbedPreviewerLink } from '@reuters-graphics/svelte-page-components';
import { init } from 'svelte-i18n';
init({ initialLocale: 'en' });
import content from '$locales/en/content.json';
</script>

<SEO
seoTitle='My page'
seoDescription='My description'
shareTitle='myShareTitle'
shareDescription='My share description'
seoTitle={content.SEOTitle}
seoDescription={content.SEODescription}
shareTitle={content.ShareTitle}
shareDescription={content.ShareDescription}
shareImgPath='images/shark.jpg'
lang='en'
/>
Expand Down
10 changes: 10 additions & 0 deletions src/FutureGraphicsComponentsLib/EndNotes/index.svelte
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
<script>
import marked from 'marked';
export let text;
if (!text) throw new Error('"text" prop must be defined as a string for BodyText components');
</script>

<section class='end-notes'>
{@html marked(text)}
</section>
10 changes: 6 additions & 4 deletions src/FutureGraphicsComponentsLib/Framer/index.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -16,13 +16,15 @@ const roundToFive = (x) => Math.ceil(x / 5) * 5;
let width = 600;
let windowInnerWidth = 1200;
let pymParent;
const resize = (newWidth) => {
localStorage.setItem('previewWidth', newWidth);
width = newWidth;
};
const reframe = (embed) => {
new pym.Parent(
pymParent = new pym.Parent(
'frame-parent',
urljoin(window.location.origin, embed)
);
Expand Down Expand Up @@ -106,7 +108,7 @@ $: if (browser) {
margin-bottom: 20px;
button {
margin: 0 4px;
background-color: #fff;
background-color:transparent;
border: 0;
color: #999;
padding: 2px 2px;
Expand All @@ -122,14 +124,14 @@ $: if (browser) {
}
#frame-parent {
border: 2px dashed #ddd;
border: 1px solid #ddd;
margin: 0 auto;
width: var(--width);
}
.resizer {
padding: 10px;
background-color: #fff;
background-color:transparent;
position: fixed;
bottom: 0;
right: 0;
Expand Down
4 changes: 2 additions & 2 deletions src/FutureGraphicsComponentsLib/PymChild/index.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@
import { onMount } from 'svelte';
import pym from 'pym.js';
let childFrame;
let pymChild;
onMount(() => {
childFrame = new pym.Child({ polling: 500 });
pymChild = new pym.Child({ polling: 500 });
});
</script>
1 change: 1 addition & 0 deletions src/FutureGraphicsComponentsLib/index.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
export { default as BodyText } from './BodyText/index.svelte';
export { default as EmbedPreviewerLink } from './EmbedPreviewerLink/index.svelte';
export { default as EndNotes } from './EndNotes/index.svelte';
export { default as Footer } from './Footer/index.svelte';
export { default as Framer } from './Framer/index.svelte';
export { default as Image } from './Image/index.svelte';
Expand Down
42 changes: 34 additions & 8 deletions src/lib/Chart.svelte
Original file line number Diff line number Diff line change
@@ -1,27 +1,53 @@
<script>
import Chart from '@reuters-graphics/parliament-chart';
import { onMount } from 'svelte';
import { _ } from 'svelte-i18n';
import debounce from 'lodash/debounce';
export let title;
export let chatter;
const colours = (p) => {
switch (p.id) {
case 'a':
return '#2c6075';
case 'b':
return '#7ebfc1';
case 'c':
return '#d1eeea';
case 'd':
return '#ffd430';
case 'e':
return '#cda200';
default:
return 'lightgrey';
}
};
onMount(() => {
const chart = new Chart();
chart
.selection('#parliament-chart')
.data([
{ id: "gop",seats: 211 },
{ id: "dem",seats: 221 }
{ id: 'a', seats: 150 },
{ id: 'b', seats: 125 },
{ id: 'c', seats: 75 },
{ id: 'd', seats: 50 },
{ id: 'e', seats: 25 },
{ id: 'f', seats: 10 },
])
.props({
circle: {
fill: (p) => p.id === 'gop' ? 'red' : 'blue',
}
fill: colours,
},
})
.draw();
})
const resize = debounce(() => { chart.draw(); }, 250);
window.addEventListener('resize', resize);
});
</script>

<section class='graphic'>
<h3>{$_('chartTitle')}</h3>
<p>{$_('chartChatter')}</p>
<h3>{title}</h3>
<p>{chatter}</p>
<div id='parliament-chart'></div>
</section>
35 changes: 21 additions & 14 deletions src/lib/Page.svelte
Original file line number Diff line number Diff line change
@@ -1,22 +1,29 @@
<script>
import { Image, BodyText } from '@reuters-graphics/svelte-page-components';
import { _ } from 'svelte-i18n';
import Chart from './Chart.svelte';
import content from '$locales/en/content.json';
import { BodyText, Image, EndNotes } from 'reuters-components';
import Chart from './Chart.svelte';
</script>


<article class='container-fluid'>
<section class="headline">
<p class="section-title color-red">Reuters Internet Fashion</p>
<h2 class="">{$_('title')}</h2>
<p>Cold simple theme for features and graphics.</p>
<p class="section-title color-red">{content.Kicker}</p>
<h2>{content.Hed}</h2>
<p>{content.Dek}</p>
</section>
<BodyText text={$_('story')} />
<Chart />
<BodyText text={$_('story')} />
<Image src='/images/shark.jpg' alt='a shark' caption='Photo by Jon' wider />
<BodyText text={$_('story')} />
{#each content.blocks as block}
{#if block.Type === 'text'}
<BodyText text={block.Text} />
{:else if block.Type === 'photo'}
<Image
src='images/shark.jpg'
caption={block.Caption}
alt={block.AltText}
wide
/>
{:else if block.Type === 'graphic'}
<Chart title={block.Title} chatter={block.Chatter} />
{/if}
{/each}

<EndNotes text={content.EndNotes} />
</article>

4 changes: 0 additions & 4 deletions src/lib/translations.js

This file was deleted.

Binary file removed src/statics/images/deeper/images/shark.jpg
Binary file not shown.
2 changes: 1 addition & 1 deletion src/statics/images/manifest.json
Original file line number Diff line number Diff line change
@@ -1 +1 @@
{"deeper/images/shark.jpg":{"width":2600,"height":1956,"size":205},"shark.jpg":{"width":1400,"height":788,"size":103}}
{"shark.jpg":{"width":1400,"height":788,"size":103}}
4 changes: 3 additions & 1 deletion src/template.html
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@
%svelte.head%
</head>
<body>
%svelte.body%
<div id='svelte-app'>
%svelte.body%
</div>
</body>
</html>
9 changes: 3 additions & 6 deletions svelte.config.cjs
Original file line number Diff line number Diff line change
Expand Up @@ -51,22 +51,19 @@ module.exports = {
routes: 'pages',
template: 'src/template.html',
},
target: '',
target: '#svelte-app',
vite: {
resolve: {
alias: {
$utils: path.resolve(__dirname, 'src/utils'),
$pkg: path.resolve(__dirname, 'package.json'),
$imgs: path.resolve(__dirname, 'src/statics/images/manifest.json'),
$locales: path.resolve(__dirname, 'locales'),
'@reuters-graphics/svelte-page-components': path.resolve(__dirname, 'src/FutureGraphicsComponentsLib/index.js'),
'reuters-components': path.resolve(__dirname, 'src/FutureGraphicsComponentsLib'),
},
},
build: {
assetsInlineLimit: 0,
},
optimizeDeps: {
exclude: ['svelte-fa', 'embeds'],
exclude: ['svelte-fa'],
},
plugins: [
dsv(),
Expand Down
Loading

0 comments on commit 1a3b8b7

Please sign in to comment.