sfc-utils 1.4.203 → 1.4.205

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.
Files changed (87) hide show
  1. package/components/helpers/utilfunctions.mjs +17 -24
  2. package/components/layout/layoutscript.mjs +10 -3
  3. package/package.json +1 -1
  4. package/settings.js +2 -2
  5. package/example/.prettierrc +0 -5
  6. package/example/README.md +0 -8
  7. package/example/gatsby-config.js +0 -137
  8. package/example/gatsby-node.js +0 -66
  9. package/example/package-lock.json +0 -31884
  10. package/example/package.json +0 -71
  11. package/example/project-config.json +0 -38
  12. package/example/src/components/layout.js +0 -96
  13. package/example/src/components/sfc/ad.js +0 -47
  14. package/example/src/components/sfc/ai2html/ai2html_template.ai +5 -1368
  15. package/example/src/components/sfc/button.js +0 -40
  16. package/example/src/components/sfc/byline.js +0 -42
  17. package/example/src/components/sfc/component-helpers/customhooks.js +0 -17
  18. package/example/src/components/sfc/component-helpers/datehelpers.js +0 -55
  19. package/example/src/components/sfc/component-helpers/newsletterhelpers.js +0 -89
  20. package/example/src/components/sfc/component-helpers/requesthelpers.js +0 -7
  21. package/example/src/components/sfc/component-helpers/scrolldownhelpers.js +0 -11
  22. package/example/src/components/sfc/component-helpers/utilfunctions.js +0 -68
  23. package/example/src/components/sfc/creditline.js +0 -35
  24. package/example/src/components/sfc/credits.js +0 -17
  25. package/example/src/components/sfc/creditssection.js +0 -49
  26. package/example/src/components/sfc/dropcap.js +0 -15
  27. package/example/src/components/sfc/footer.js +0 -36
  28. package/example/src/components/sfc/geocoder.js +0 -148
  29. package/example/src/components/sfc/misccredit.js +0 -17
  30. package/example/src/components/sfc/navtop.js +0 -121
  31. package/example/src/components/sfc/newsletter.js +0 -157
  32. package/example/src/components/sfc/relatedlink.js +0 -23
  33. package/example/src/components/sfc/relatedrow.js +0 -23
  34. package/example/src/components/sfc/relatedsection.js +0 -27
  35. package/example/src/components/sfc/safelink.js +0 -86
  36. package/example/src/components/sfc/scrolldown.js +0 -22
  37. package/example/src/components/sfc/sharebuttons.js +0 -93
  38. package/example/src/components/sfc/topper.js +0 -88
  39. package/example/src/components/sfc/video.js +0 -74
  40. package/example/src/components/sfc/wcmimage.js +0 -131
  41. package/example/src/data/sfc/images/react.gif +0 -0
  42. package/example/src/data/sfc/related_links.json +0 -17
  43. package/example/src/html.js +0 -41
  44. package/example/src/pages/index.js +0 -166
  45. package/example/src/styles/credittooltip.less +0 -55
  46. package/example/src/styles/footer.less +0 -378
  47. package/example/src/styles/modules/ad.module.less +0 -21
  48. package/example/src/styles/modules/ai2html.module.less +0 -19
  49. package/example/src/styles/modules/button.module.less +0 -94
  50. package/example/src/styles/modules/byline.module.less +0 -11
  51. package/example/src/styles/modules/creditline.module.less +0 -12
  52. package/example/src/styles/modules/credits.module.less +0 -7
  53. package/example/src/styles/modules/creditssection.module.less +0 -17
  54. package/example/src/styles/modules/dropcap.module.less +0 -18
  55. package/example/src/styles/modules/geocoder.module.less +0 -79
  56. package/example/src/styles/modules/newsletter.module.less +0 -147
  57. package/example/src/styles/modules/relatedlink.module.less +0 -28
  58. package/example/src/styles/modules/relatedrow.module.less +0 -8
  59. package/example/src/styles/modules/relatedsection.module.less +0 -19
  60. package/example/src/styles/modules/scrolldown.module.less +0 -31
  61. package/example/src/styles/modules/share.module.less +0 -22
  62. package/example/src/styles/modules/topper.module.less +0 -63
  63. package/example/src/styles/modules/video.module.less +0 -27
  64. package/example/src/styles/modules/wcmimage.module.less +0 -20
  65. package/example/src/styles/nav.less +0 -187
  66. package/example/src/styles/old css/defaults.less +0 -99
  67. package/example/src/styles/old css/footer.less +0 -345
  68. package/example/src/styles/old css/nav.less +0 -187
  69. package/example/src/styles/old css/project.less +0 -1
  70. package/example/src/styles/old css/reset.css +0 -95
  71. package/example/src/styles/old css/seed.less +0 -7
  72. package/example/src/styles/old css/typography.css +0 -168
  73. package/example/src/styles/old css/values.less +0 -74
  74. package/example/src/styles/project.less +0 -1
  75. package/example/src/styles/reset.css +0 -97
  76. package/example/src/styles/seed.less +0 -6
  77. package/example/src/styles/values.less +0 -203
  78. package/example/src/styles/variables.less +0 -142
  79. package/example/static/manifest.webmanifest +0 -1
  80. package/example/tasks/create-c2p-sheet.js +0 -6
  81. package/example/tasks/deploy-addon.py +0 -14
  82. package/example/tasks/google-docs.js +0 -16
  83. package/example/tasks/google-sheets.js +0 -17
  84. package/example/tasks/node-helpers.js +0 -81
  85. package/example/tasks/post-build.sh +0 -7
  86. package/example/tasks/pre-build.sh +0 -18
  87. package/example/tempsettings.js +0 -28
@@ -1,74 +0,0 @@
1
- import React from 'react'
2
- import PropTypes from 'prop-types'
3
- import videoStyles from '../../styles/modules/video.module.less'
4
-
5
- export default function Video({
6
- id,
7
- containerClass,
8
- innerContainerClass,
9
- videoClass,
10
- autoPlay = true,
11
- loop = true,
12
- muted = true,
13
- alt,
14
- cap,
15
- cred,
16
- }) {
17
- return (
18
- <figure className={containerClass ? containerClass : videoStyles.container}>
19
- <div
20
- className={
21
- innerContainerClass
22
- ? innerContainerClass
23
- : innerContainerClass === null
24
- ? ''
25
- : videoStyles.responsiveContainer
26
- }
27
- >
28
- <video
29
- className={videoClass ? videoClass : videoStyles.default}
30
- autoPlay={autoPlay}
31
- loop={loop}
32
- muted={muted}
33
- preload="auto"
34
- alt={alt}
35
- poster={`https://files.sfchronicle.com/static-assets/compression-bot/${id}.jpg`}
36
- >
37
- <source
38
- src={`https://files.sfchronicle.com/static-assets/compression-bot/${id}.mp4`}
39
- type="video/mp4"
40
- />
41
- <source
42
- src={`https://files.sfchronicle.com/static-assets/compression-bot/${id}.m3u8`}
43
- type="application/x-mpegURL"
44
- />
45
- </video>
46
- </div>
47
- {cap && cred && (
48
- <figcaption className={videoStyles.cFigCap}>
49
- {cap} <span className={videoStyles.cFigCred}>{cred}</span>
50
- </figcaption>
51
- )}
52
- {!cap && cred && (
53
- <figcaption className={videoStyles.cFigCap}>
54
- <span className={videoStyles.cFigCred}>{cred}</span>
55
- </figcaption>
56
- )}
57
- {cap && !cred && (
58
- <figcaption className={videoStyles.cFigCap}>{cap}</figcaption>
59
- )}
60
- </figure>
61
- )
62
- }
63
-
64
- Video.propTypes = {
65
- id: PropTypes.string.isRequired,
66
- videoClass: PropTypes.string,
67
- containerClass: PropTypes.string,
68
- autoPlay: PropTypes.bool,
69
- loop: PropTypes.bool,
70
- muted: PropTypes.bool,
71
- alt: PropTypes.string.isRequired,
72
- cred: PropTypes.string,
73
- cap: PropTypes.string,
74
- }
@@ -1,131 +0,0 @@
1
- import React, {useRef, useEffect, useLayoutEffect, useState} from 'react'
2
- import LazyLoad from 'react-lazyload'
3
- import PropTypes from 'prop-types'
4
- import * as wcmimageStyles from '../../styles/modules/wcmimage.module.less'
5
- import { useStaticQuery, graphql } from "gatsby"
6
- import { debounce } from '../sfc/component-helpers/utilfunctions'
7
-
8
- const currentEnv = process.env.GATSBY_DEPLOY_ENV
9
-
10
- const WCMImage = ({ wcm, alt, cap, cred, lz, className, ratio }) => {
11
- // When the wrapping div is rendered, we're going to figure out the best size for this image to be
12
- let picRef = useRef(null)
13
- let [imageRez, setImageRez] = useState(0)
14
-
15
- let setImageWidth = () => {
16
- let pixelWidth = 900 // Default width if we need a fallback
17
- let pixelRatio = window.devicePixelRatio || 1
18
- if (picRef.current && picRef.current.offsetWidth){
19
- pixelWidth = Math.round(picRef.current.offsetWidth * pixelRatio)
20
- }
21
- if (imageRez < pixelWidth){ // No need to resize if we're just scaling down
22
- setImageRez(pixelWidth)
23
- }
24
- }
25
-
26
- useEffect(() => {
27
- const debouncedHandleResize = debounce(function handleResize() {
28
- setImageWidth()
29
- }, 500)
30
- window.addEventListener('resize', debouncedHandleResize)
31
-
32
- return () => {
33
- window.removeEventListener('resize', debouncedHandleResize)
34
- }
35
- })
36
-
37
- useEffect(() => {
38
- setImageWidth()
39
- }, [])
40
-
41
- // Use GraphQL to grab the data for the WCM photo we want
42
- const data = useStaticQuery(graphql`
43
- query PhotoQuery {
44
- allWcmPhotos {
45
- nodes {
46
- photo {
47
- ratio
48
- wcmid
49
- full_path
50
- }
51
- }
52
- }
53
- }
54
- `)
55
-
56
- let photoRatio = "56.25%"; // Default to 16/9
57
- let fullPath = `https://s.hdnux.com/photos/0/0/0/${wcm}/0/`;
58
- if (!ratio){
59
- let matchedPhoto = data.allWcmPhotos.nodes.find((item) => {
60
- return item.photo.wcmid.toString() === wcm.toString()
61
- })
62
- if (!matchedPhoto && currentEnv !== "development"){
63
- throw `WCMImage error: No matching ID for ${wcm} present in the array at the top of gatsby-node.js! If it's already there, you might need to reboot dev.`
64
- }
65
- if (matchedPhoto){
66
- // Set ratio of the actual photo like a legit hacker
67
- photoRatio = (matchedPhoto.photo.ratio*100)+"%";
68
- fullPath = matchedPhoto.photo.full_path;
69
- } else {
70
- // Alert that things will go wrong on deploy
71
- console.error(`No matching ID for ${wcm} found in gatsby-node.js! This is fine for development, but it will error on deploy!`);
72
- }
73
- } else {
74
- // If an override is being passed in, use that
75
- photoRatio = ratio
76
- }
77
-
78
- // Get serious about alt tags
79
- if (typeof alt !== "string"){
80
- throw `WCMImage error: Image for ${wcm} needs an alt tag! Please add a good, descriptive alt tag. Suggestion from Mozilla: When choosing alt strings for your images, imagine what you would say when reading the page to someone over the phone without mentioning that there's an image on the page.`
81
- }
82
-
83
- // Conditionally lazyload if we want to and have the capability
84
- const ConditionalWrapper = ({ condition, wrapper, children }) =>
85
- condition ? wrapper(children) : children;
86
-
87
- return (
88
- <figure className={className ? className : ""}>
89
- <div ref={picRef} style={{paddingBottom: photoRatio, overflow: "hidden", position: "relative"}}>
90
- <ConditionalWrapper
91
- condition={!lz}
92
- wrapper={children => <LazyLoad offset={300} resize once>{children}</LazyLoad>}
93
- >
94
- {imageRez > 0 &&
95
- <img style={{position: "absolute"}}
96
- className={wcmimageStyles.cImg}
97
- // "lazy" won't work on older browsers, which is why we use LazyLoad conditionally
98
- loading="lazy"
99
- src={`${fullPath}${imageRez}x0.jpg`}
100
- // PLEASE INCLUDE ALTS
101
- alt={alt}
102
- />
103
- }
104
- </ConditionalWrapper>
105
- </div>
106
- {cap && cred && (
107
- <figcaption className={wcmimageStyles.cFigCap}>
108
- {cap} <span className={wcmimageStyles.cFigCred}>{cred}</span>
109
- </figcaption>
110
- )}
111
- {!cap && cred && (
112
- <figcaption className={wcmimageStyles.cFigCap}>
113
- <span className={wcmimageStyles.cFigCred}>{cred}</span>
114
- </figcaption>
115
- )}
116
- {cap && !cred && (
117
- <figcaption className={wcmimageStyles.cFigCap}>{cap}</figcaption>
118
- )}
119
- </figure>
120
- )
121
- }
122
-
123
- WCMImage.propTypes = {
124
- wcm: PropTypes.oneOfType([PropTypes.string, PropTypes.number]).isRequired,
125
- // alt: PropTypes.string.isRequired,
126
- cap: PropTypes.string,
127
- cred: PropTypes.string,
128
- className: PropTypes.string,
129
- }
130
-
131
- export default WCMImage
@@ -1,17 +0,0 @@
1
- [
2
- {
3
- "title": "TK TITLE1",
4
- "url": "https://www.sfchronicle.com",
5
- "wcmid": 20374215
6
- },
7
- {
8
- "title": "TK TITLE2",
9
- "url": "https://www.sfchronicle.com",
10
- "wcmid": 20374215
11
- },
12
- {
13
- "title": "TK TITLE3",
14
- "url": "https://www.sfchronicle.com",
15
- "wcmid": 20374215
16
- }
17
- ]
@@ -1,41 +0,0 @@
1
- import React from "react"
2
- import PropTypes from "prop-types"
3
- import LayoutScript from "../../components/layout/layoutscript.mjs"
4
-
5
- export default function HTML(props) {
6
- return (
7
- <html {...props.htmlAttributes}>
8
- <head>
9
- <meta charSet="utf-8" />
10
- <meta httpEquiv="x-ua-compatible" content="ie=edge" />
11
- <meta
12
- name="viewport"
13
- content="width=device-width, initial-scale=1, shrink-to-fit=no"
14
- />
15
- <LayoutScript/>
16
- {props.headComponents}
17
- </head>
18
- <body {...props.bodyAttributes} is="responsive-body">
19
- {props.preBodyComponents}
20
- <noscript key="noscript" id="gatsby-noscript">
21
- This app works best with JavaScript enabled.
22
- </noscript>
23
- <div
24
- key={`body`}
25
- id="___gatsby"
26
- dangerouslySetInnerHTML={{ __html: props.body }}
27
- />
28
- {props.postBodyComponents}
29
- </body>
30
- </html>
31
- )
32
- }
33
-
34
- HTML.propTypes = {
35
- htmlAttributes: PropTypes.object,
36
- headComponents: PropTypes.array,
37
- bodyAttributes: PropTypes.object,
38
- preBodyComponents: PropTypes.array,
39
- body: PropTypes.string,
40
- postBodyComponents: PropTypes.array,
41
- }
@@ -1,166 +0,0 @@
1
- import React from 'react'
2
- import { graphql } from 'gatsby'
3
- import PropTypes from 'prop-types'
4
- import Layout from '../components/layout'
5
- import WCMImage from '../components/sfc/wcmimage'
6
- import DropCap from '../components/sfc/dropcap'
7
- import { useCanNativeLazyLoad } from '../components/sfc/component-helpers/customhooks'
8
- import RelatedSection from '../components/sfc/relatedsection'
9
- import CreditsSection from '../components/sfc/creditssection'
10
- import Ad from '../components/sfc/ad'
11
- import Newsletter from '../components/sfc/newsletter'
12
- import NavTop from '../components/sfc/navtop'
13
- import Byline from '../../../components/byline.mjs'
14
- import Topper2 from '../../../components/topper2.mjs'
15
- import OgPubDate from '../../../components/ogpubdate.mjs'
16
-
17
- let rawCredits;
18
- try {
19
- rawCredits = require('../data/credits.sheet.json')
20
- } catch (err) {
21
- // It's fine
22
- rawCredits = null;
23
- }
24
-
25
- let related_links;
26
- try {
27
- related_links = require('../data/related_links.sheet.json')
28
- } catch(err) {
29
- related_links = require('../data/sfc/related_links.json')
30
- }
31
-
32
- let topperSettings;
33
- try {
34
- topperSettings = require('../data/topper2_settings.sheet.json')
35
- } catch {
36
- topperSettings = null;
37
- }
38
-
39
- const IndexPage = ({ data }) => {
40
- // easy hooks based request library
41
- // const { data: responseData, error } = useSWR('https://api.kanye.rest', getData, {
42
- // onSuccess: (data) => console.log(data),
43
- // onError: (err) => console.log(err),
44
- // })
45
-
46
- // custom hook checks for nativelazyload
47
- const lazy = useCanNativeLazyLoad()
48
-
49
- const {
50
- site: { siteMetadata },
51
- allRelatedLinksJson: { nodes: relatedLinks },
52
- allWcmPhotos
53
- } = data
54
-
55
- return (
56
- <Layout meta={siteMetadata}>
57
- <NavTop meta={siteMetadata} />
58
- <Topper2 settings={topperSettings[0]} wcmData={allWcmPhotos}/>
59
- <Byline meta={siteMetadata}/>
60
- <main>
61
- <article>
62
- <p>
63
- <DropCap>T</DropCap>
64
- he Savage nodded, frowning. "You got rid of them. Yes, that's just
65
- like you. Getting rid of everything unpleasant instead of learning
66
- to put up with it. Whether 'tis better in the mind to suffer the
67
- slings and arrows or outrageous fortune, or to take arms against a
68
- sea of troubles and by opposing end them... But you don't do either.
69
- Neither suffer nor oppose. You just abolish the slings and arrows.
70
- It's too easy."
71
- </p>
72
-
73
- <p>
74
- The Savage nodded, frowning. "You got rid of them. Yes, that's just
75
- like you. Getting rid of everything unpleasant instead of learning
76
- to put up with it. Whether 'tis better in the mind to suffer the
77
- slings and arrows or outrageous fortune, or to take arms against a
78
- sea of troubles and by opposing end them... But you don't do either.
79
- Neither suffer nor oppose. You just abolish the slings and arrows.
80
- It's too easy."
81
- </p>
82
-
83
- {/* Wrapping div supports "embed-" + center/left/right/full classes */}
84
- <div className="embed-center">
85
- <WCMImage wcm={20374215} alt="TKTKTK" lz={lazy} cap={"TKTKTK caption"} />
86
- </div>
87
-
88
- <p>
89
- The Savage nodded, frowning. "You got rid of them. Yes, that's just
90
- like you. Getting rid of everything unpleasant instead of learning
91
- to put up with it. Whether 'tis better in the mind to suffer the
92
- slings and arrows or outrageous fortune, or to take arms against a
93
- sea of troubles and by opposing end them... But you don't do either.
94
- Neither suffer nor oppose. You just abolish the slings and arrows.
95
- It's too easy."
96
- </p>
97
-
98
- <Ad adLetter="A" />
99
-
100
- <Newsletter />
101
- </article>
102
- </main>
103
-
104
- <RelatedSection links={related_links} />
105
- <OgPubDate />
106
- {rawCredits && <CreditsSection creditsData={rawCredits}/>}
107
- </Layout>
108
- )
109
- }
110
-
111
- export const query = graphql`
112
- {
113
- site {
114
- siteMetadata {
115
- EMBEDDED
116
- MAIN_DOMAIN
117
- PAYWALL_SETTING
118
- PROJECT {
119
- AUTHORS {
120
- AUTHOR_NAME
121
- AUTHOR_PAGE
122
- }
123
- DATE
124
- DESCRIPTION
125
- HEARST_CATEGORY
126
- KEY_SUBJECTS
127
- DECK
128
- DISPLAY_TITLE
129
- IMAGE
130
- ISO_MODDATE
131
- ISO_PUBDATE
132
- OPT_SLASH
133
- SLUG
134
- SOCIAL_TITLE
135
- SUBFOLDER
136
- TITLE
137
- TWITTER_TEXT
138
- ANALYTICS_CREDIT
139
- MARKET_KEY
140
- CANONICAL_URL
141
- }
142
- }
143
- }
144
- allRelatedLinksJson {
145
- nodes {
146
- wcmid
147
- title
148
- url
149
- }
150
- }
151
- allWcmPhotos {
152
- nodes {
153
- photo {
154
- ratio
155
- wcmid
156
- full_path
157
- }
158
- }
159
- }
160
- }
161
- `
162
- IndexPage.propTypes = {
163
- data: PropTypes.object.isRequired,
164
- }
165
-
166
- export default IndexPage
@@ -1,55 +0,0 @@
1
- @import (less) '../../../styles/variables.less';
2
-
3
- body .__react_component_tooltip {
4
- box-shadow: 0 1px 3px rgba(0, 0, 0, 20%);
5
- padding: 6px @s4;
6
- pointer-events: all;
7
-
8
- .flex-contact {
9
- display: flex;
10
- align-items: center;
11
-
12
- a {
13
- &:visited {
14
- color: @black;
15
- }
16
- &:hover {
17
- opacity: 0.6;
18
- color: @black;
19
- }
20
- }
21
- .svg-wrapper {
22
- width: 25px;
23
- height: 25px;
24
- border-radius: 25px;
25
- border: 1px solid @black;
26
- margin: 0 2px;
27
- }
28
- svg {
29
- width: 100%;
30
- padding: @s4;
31
- // margin: 0 3px;
32
- }
33
- }
34
- }
35
-
36
- .contact-name, .font-awesome a {
37
- color: @black;
38
- text-decoration: underline;
39
- text-decoration-thickness: 1px;
40
- text-decoration-color: @grey-75;
41
- cursor: pointer;
42
-
43
- &:hover {
44
- color: @grey-50;
45
- }
46
- }
47
-
48
- .contact-name[data-tip="{}"] {
49
- text-decoration: none;
50
- color: @black;
51
- &:hover {
52
- color: inherit;
53
- cursor: inherit;
54
- }
55
- }