46 lines
11 KiB
JavaScript
46 lines
11 KiB
JavaScript
import{S as F,i as Y,s as z,g as y,m as _,t as h,h as g,j as k,x as ee,D as te,W as ie,y as W,o as V,k as ae,b as w,F as I,c as G,d as D,e as ne,v as E,w as M,f as C,E as re,l as H,u as J,q as K,r as Q,C as N,n as se}from"./index-4f5e5369.js";import{g as X,a as Z}from"./spread-8a54911c.js";import{p as oe,M as le,T as ce,S as q}from"./collect-stories-6e37d46b.js";import{G as fe}from"./GraphicBlock-fdcf18df.js";import{b as pe,w as de}from"./withParams-47e2ab71.js";import"./Block-67c7bec3.js";import"./PaddingReset-bdb61f35.js";import"./marked.esm-76161808.js";const me=`Easily add a responsive Datawrapper embed on your page.
|
|
|
|
\`\`\`svelte
|
|
<script>
|
|
import { DatawrapperChart } from '@reuters-graphics/graphics-components';
|
|
<\/script>
|
|
|
|
<DatawrapperChart
|
|
title="Global abortion access"
|
|
ariaLabel="map"
|
|
id="abortion-rights-map"
|
|
src="https://graphics.reuters.com/USA-ABORTION/lgpdwggnwvo/media-embed.html"
|
|
/>
|
|
\`\`\`
|
|
|
|
##### Getting the chart URL for \`src\`
|
|
|
|
Copy the source url for the Datawrapper chart in the \`src\` prop.
|
|
You can get this from the published url on Reuters Graphics.
|
|
|
|
- Publish the chart on Datawrapper.
|
|
- Go to the **Datawrapper charts** Teams channel, wait for the graphic to finish publishing.
|
|
- Inside **Embed code (for developers only)**, find and copy the url inside the \`src\` prop. (It ends in \`media-embed.html\`.)
|
|
|
|
**Note:** There is no need to update the url if you update the chart inside Datawrapper. Any changes will be automatically reflected.
|
|
`,ue=`By default, Datawrapper will export your chart with the chart chatter like title, description and notes.
|
|
|
|
At the moment, these don't _exactly_ match our styles and can't be made to fit into the article well.
|
|
|
|
Instead, it's often better to remove all the text from your Datawrapper chart before publishing it and add that text back via the component props.
|
|
`,he=r=>({}),B=r=>({}),ge=r=>({}),U=r=>({});function P(r){let t;const a=r[12].title,e=H(a,r,r[14],U);return{c(){e&&e.c()},m(i,n){e&&e.m(i,n),t=!0},p(i,n){e&&e.p&&(!t||n&16384)&&J(e,a,i,i[14],t?Q(a,i[14],n,ge):K(i[14]),U)},i(i){t||(h(e,i),t=!0)},o(i){g(e,i),t=!1},d(i){e&&e.d(i)}}}function j(r){let t;const a=r[12].notes,e=H(a,r,r[14],B);return{c(){e&&e.c()},m(i,n){e&&e.m(i,n),t=!0},p(i,n){e&&e.p&&(!t||n&16384)&&J(e,a,i,i[14],t?Q(a,i[14],n,he):K(i[14]),B)},i(i){t||(h(e,i),t=!0)},o(i){g(e,i),t=!1},d(i){e&&e.d(i)}}}function we(r){let t,a,e,i,n,u,p,f=r[11].title&&P(r),c=r[11].notes&&j(r);return{c(){f&&f.c(),t=W(),a=V("div"),e=V("iframe"),n=W(),c&&c.c(),u=ae(),w(e,"title",r[2]),w(e,"aria-label",r[4]),w(e,"id",r[5]),I(e.src,i=r[6])||w(e,"src",i),w(e,"scrolling",r[7]),w(e,"frameborder","0"),G(e,"width","0"),G(e,"min-width","100%",1),G(e,"border","none"),w(a,"class","datawrapper-chart")},m(o,d){f&&f.m(o,d),D(o,t,d),D(o,a,d),ne(a,e),r[13](e),D(o,n,d),c&&c.m(o,d),D(o,u,d),p=!0},p(o,d){o[11].title?f?(f.p(o,d),d&2048&&h(f,1)):(f=P(o),f.c(),h(f,1),f.m(t.parentNode,t)):f&&(E(),g(f,1,1,()=>{f=null}),M()),(!p||d&4)&&w(e,"title",o[2]),(!p||d&16)&&w(e,"aria-label",o[4]),(!p||d&32)&&w(e,"id",o[5]),(!p||d&64&&!I(e.src,i=o[6]))&&w(e,"src",i),(!p||d&128)&&w(e,"scrolling",o[7]),o[11].notes?c?(c.p(o,d),d&2048&&h(c,1)):(c=j(o),c.c(),h(c,1),c.m(u.parentNode,u)):c&&(E(),g(c,1,1,()=>{c=null}),M())},i(o){p||(h(f),h(c),p=!0)},o(o){g(f),g(c),p=!1},d(o){o&&(C(t),C(a),C(n),C(u)),f&&f.d(o),r[13](null),c&&c.d(o)}}}function be(r){let t,a;return t=new fe({props:{width:r[8],textWidth:r[9],title:r[0],description:r[1],notes:r[3],$$slots:{default:[we]},$$scope:{ctx:r}}}),{c(){y(t.$$.fragment)},m(e,i){_(t,e,i),a=!0},p(e,[i]){const n={};i&256&&(n.width=e[8]),i&512&&(n.textWidth=e[9]),i&1&&(n.title=e[0]),i&2&&(n.description=e[1]),i&8&&(n.notes=e[3]),i&19700&&(n.$$scope={dirty:i,ctx:e}),t.$set(n)},i(e){a||(h(t.$$.fragment,e),a=!0)},o(e){g(t.$$.fragment,e),a=!1},d(e){k(t,e)}}}function ye(r,t,a){let e,{$$slots:i={},$$scope:n}=t;const u=ee(i);let{title:p=null}=t,{description:f=null}=t,{frameTitle:c=""}=t,{notes:o=null}=t,{ariaLabel:d=""}=t,{id:v=""}=t,{src:s}=t,{scrolling:m="no"}=t,{width:A="normal"}=t,{textWidth:T="normal"}=t,b;te(()=>{typeof window<"u"&&window.addEventListener("message",e)}),ie(()=>{typeof window<"u"&&window.removeEventListener("message",e)});function $(l){re[l?"unshift":"push"](()=>{b=l,a(10,b)})}return r.$$set=l=>{"title"in l&&a(0,p=l.title),"description"in l&&a(1,f=l.description),"frameTitle"in l&&a(2,c=l.frameTitle),"notes"in l&&a(3,o=l.notes),"ariaLabel"in l&&a(4,d=l.ariaLabel),"id"in l&&a(5,v=l.id),"src"in l&&a(6,s=l.src),"scrolling"in l&&a(7,m=l.scrolling),"width"in l&&a(8,A=l.width),"textWidth"in l&&a(9,T=l.textWidth),"$$scope"in l&&a(14,n=l.$$scope)},r.$$.update=()=>{r.$$.dirty&1024&&(e=l=>{if(l.data["datawrapper-height"]!==void 0){const R=[b];for(const x in l.data["datawrapper-height"])for(let S=0;S<R.length;S++)R[S].contentWindow===l.source&&(R[S].style.height=l.data["datawrapper-height"][x]+"px")}})},[p,f,c,o,d,v,s,m,A,T,b,u,i,$,n]}class L extends F{constructor(t){super(),Y(this,t,ye,be,z,{title:0,description:1,frameTitle:2,notes:3,ariaLabel:4,id:5,src:6,scrolling:7,width:8,textWidth:9})}}L.__docgen={version:3,name:"DatawrapperChart.svelte",data:[{keywords:[{name:"type",description:"{string}"}],visibility:"public",description:"Title of the graphic",name:"title",kind:"let",static:!1,readonly:!1,type:{kind:"type",text:"string",type:"string"},defaultValue:null},{keywords:[{name:"type",description:"{string}"}],visibility:"public",description:"Description of the graphic, passed in as a markdown string.",name:"description",kind:"let",static:!1,readonly:!1,type:{kind:"type",text:"string",type:"string"},defaultValue:null},{keywords:[{name:"required",description:""}],visibility:"public",description:"iframe title",name:"frameTitle",kind:"let",static:!1,readonly:!1,type:{kind:"type",text:"string",type:"string"},defaultValue:""},{keywords:[{name:"type",description:"{string}"}],visibility:"public",description:"Notes to the graphic, passed in as a markdown string.",name:"notes",kind:"let",static:!1,readonly:!1,type:{kind:"type",text:"string",type:"string"},defaultValue:null},{keywords:[{name:"required",description:""}],visibility:"public",description:"iframe aria label",name:"ariaLabel",kind:"let",static:!1,readonly:!1,type:{kind:"type",text:"string",type:"string"},defaultValue:""},{keywords:[],visibility:"public",description:"iframe id",name:"id",kind:"let",static:!1,readonly:!1,type:{kind:"type",text:"string",type:"string"},defaultValue:""},{keywords:[{name:"required",description:""}],visibility:"public",description:"Datawrapper embed URL",name:"src",kind:"let",static:!1,readonly:!1,type:{kind:"type",text:"any",type:"any"}},{keywords:[],visibility:"public",description:"iframe scrolling option",name:"scrolling",kind:"let",static:!1,readonly:!1,type:{kind:"type",text:"string",type:"string"},defaultValue:"no"},{keywords:[],visibility:"public",description:"Width of the chart within the text well.",name:"width",kind:"let",static:!1,readonly:!1,type:{kind:"type",text:"string",type:"string"},defaultValue:"normal"},{keywords:[{name:"type",description:"{string}"}],visibility:"public",description:`Set a different width for the text within the text well, for example,
|
|
"normal" to keep the title, description and notes inline with the rest
|
|
of the text well. Can't ever be wider than \`width\`.`,name:"textWidth",kind:"let",static:!1,readonly:!1,type:{kind:"type",text:"string",type:"string"},defaultValue:"normal"}],computed:[],methods:[],components:[],description:null,keywords:[],events:[],slots:[{keywords:[],visibility:"public",description:"Custom headline and chatter slot",name:"title"},{keywords:[],visibility:"public",description:"Custom notes and source slot",name:"notes"}],refs:[]};function _e(r){let t,a;const e=[r[1]];let i={};for(let n=0;n<e.length;n+=1)i=N(i,e[n]);return t=new L({props:i}),{c(){y(t.$$.fragment)},m(n,u){_(t,n,u),a=!0},p(n,u){const p=u&2?X(e,[Z(n[1])]):{};t.$set(p)},i(n){a||(h(t.$$.fragment,n),a=!0)},o(n){g(t.$$.fragment,n),a=!1},d(n){k(t,n)}}}function ke(r){let t,a;return t=new L({props:{frameTitle:"Global abortion access",ariaLabel:"map",id:"abortion-rights-map",src:"https://reuters.com/graphics/USA-ABORTION/lgvdwemlbpo/media-embed.html",title:"Global abortion access",description:"A map of worldwide access to abortion.",notes:`Note: Different indicators and additional restrictions, including different gestational limits, apply in some countries. Refer to source for full classification. Current as of May 4, 2022.
|
|
|
|
Source: Center for Reproductive Rights`}}),{c(){y(t.$$.fragment)},m(e,i){_(t,e,i),a=!0},p:se,i(e){a||(h(t.$$.fragment,e),a=!0)},o(e){g(t.$$.fragment,e),a=!1},d(e){k(t,e)}}}function De(r){let t,a,e,i,n,u,p,f;const c=[{title:"Components/DatawrapperChart"},{component:L},r[0]];let o={};for(let s=0;s<c.length;s+=1)o=N(o,c[s]);t=new le({props:o}),e=new ce({props:{$$slots:{default:[_e,({args:s})=>({1:s}),({args:s})=>s?2:0]},$$scope:{ctx:r}}}),n=new q({props:{name:"Default",args:{src:"https://reuters.com/graphics/USA-ABORTION/lgpdwggnwvo/media-embed.html",id:"abortion-rights-map",ariaLabel:"map",frameTitle:"Global abortion access"}}});const d=[{name:"With chatter"},pe(ue)];let v={$$slots:{default:[ke]},$$scope:{ctx:r}};for(let s=0;s<d.length;s+=1)v=N(v,d[s]);return p=new q({props:v}),{c(){y(t.$$.fragment),a=W(),y(e.$$.fragment),i=W(),y(n.$$.fragment),u=W(),y(p.$$.fragment)},m(s,m){_(t,s,m),D(s,a,m),_(e,s,m),D(s,i,m),_(n,s,m),D(s,u,m),_(p,s,m),f=!0},p(s,[m]){const A=m&1?X(c,[c[0],c[1],Z(s[0])]):{};t.$set(A);const T={};m&6&&(T.$$scope={dirty:m,ctx:s}),e.$set(T);const b={};m&4&&(b.$$scope={dirty:m,ctx:s}),p.$set(b)},i(s){f||(h(t.$$.fragment,s),h(e.$$.fragment,s),h(n.$$.fragment,s),h(p.$$.fragment,s),f=!0)},o(s){g(t.$$.fragment,s),g(e.$$.fragment,s),g(n.$$.fragment,s),g(p.$$.fragment,s),f=!1},d(s){s&&(C(a),C(i),C(u)),k(t,s),k(e,s),k(n,s),k(p,s)}}}function Ce(r){return[{...de(me),argTypes:{width:{control:"select",options:["normal","wide","wider","widest","fluid"]}}}]}class ve extends F{constructor(t){super(),Y(this,t,Ce,De,z,{})}}const O=oe(ve,{meta:{title:"Components/DatawrapperChart"},stories:{"tpl:default":{name:"default",template:!0,source:"<DatawrapperChart {...args} />",hasArgs:!0},Default:{name:"Default",template:!1,source:"",hasArgs:!1},WithChatter:{name:"With chatter",template:!1,source:`<DatawrapperChart
|
|
frameTitle="Global abortion access"
|
|
ariaLabel="map"
|
|
id="abortion-rights-map"
|
|
src="https://reuters.com/graphics/USA-ABORTION/lgvdwemlbpo/media-embed.html"
|
|
title="Global abortion access"
|
|
description="A map of worldwide access to abortion."
|
|
notes="{'Note: Different indicators and additional restrictions, including different gestational limits, apply in some countries. Refer to source for full classification. Current as of May 4, 2022.
|
|
|
|
Source: Center for Reproductive Rights'}"
|
|
/>`,hasArgs:!1}},allocatedIds:["default","Meta","Template","Story","componentDocs","withChatterDocs","DatawrapperChart","withComponentDocs","withStoryDocs"]}),Oe=O.meta,Ve=["Default","WithChatter"],Ie=O.stories.Default,Ee=O.stories.WithChatter;export{Ie as Default,Ee as WithChatter,Ve as __namedExportsOrder,Oe as default};
|
|
//# sourceMappingURL=DatawrapperChart.stories-6c636923.js.map
|