Skip to content

Commit 7055a13

Browse files
committed
Merge branch 'master' of https://github.com/clay/clay-starter into code-component-youtube
2 parents 02d55f9 + db4486d commit 7055a13

File tree

12 files changed

+266
-11
lines changed

12 files changed

+266
-11
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
## What does this PR do?
2+
3+
[Issue/Story](LINK_TO_STORY)
4+
5+
### Why are we doing this? Any context or related work?
6+
7+
#### Where should a reviewer start?
8+
9+
### Manual testing steps?
10+
11+
##### Screenshots
12+
13+
### Additional Context

app/components/article/schema.yaml

+1
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,7 @@ content:
6161
- image
6262
- code-sample
6363
- youtube
64+
- list
6465

6566
ledeUrl:
6667
_label: Lede Image URL

app/components/list/bootstrap.yml

+5
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
_components:
2+
list:
3+
items: []
4+
sass: ''
5+
listType: ''

app/components/list/model.js

+31
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
'use strict';
2+
3+
const striptags = require('striptags'),
4+
{ has, isFieldEmpty } = require('../../services/universal/utils'),
5+
{ render } = require('../../services/universal/styles'),
6+
{ toSmartText } = require('../../services/universal/sanitize');
7+
8+
module.exports.save = function (uri, data) {
9+
const allowedTags = ['strong', 'em', 's', 'a', 'span'];
10+
11+
data.listType = data.orderedList ? 'ol' : 'ul';
12+
13+
if (has(data.items)) {
14+
data.items.forEach((item) => {
15+
item.text = toSmartText(striptags(item.text, allowedTags));
16+
});
17+
}
18+
19+
if (isFieldEmpty(data.sass)) {
20+
delete data.css;
21+
22+
return data;
23+
} else {
24+
return render(uri, data.sass)
25+
.then((css) => {
26+
data.css = css;
27+
28+
return data;
29+
});
30+
}
31+
};

app/components/list/schema.yml

+51
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
_description: |
2+
A simple and semantic list of text items which can take custom styling.
3+
4+
items:
5+
_label: List Items
6+
_has:
7+
input: complex-list
8+
props:
9+
- prop: text
10+
_label: Text
11+
_has:
12+
input: wysiwyg
13+
styled: true
14+
buttons:
15+
- bold
16+
- italic
17+
- strike
18+
- link
19+
validate:
20+
required: true
21+
22+
orderedList:
23+
_label: Ordered List
24+
_has:
25+
input: checkbox
26+
help: Select when the list items have a strict order. E.g. ranked items, or steps in a process
27+
28+
customIndicator:
29+
_label: Use Custom Indicator
30+
_has:
31+
input: checkbox
32+
help: Use a custom list item indicator instead of the browser's default. This can be targeted in per-instance styles using '&.custom-indicator ul .text-list-item:before'
33+
34+
sass:
35+
_label: Custom Styles
36+
_has:
37+
input: codemirror
38+
mode: text/x-scss
39+
help: Custom styles for this specific component, can be written in CSS/SASS.
40+
41+
_groups:
42+
settings:
43+
fields:
44+
- items (List Items)
45+
- orderedList (Settings)
46+
- customIndicator (Settings)
47+
- sass (Settings)
48+
_placeholder:
49+
text: New List
50+
height: 30px
51+
ifEmpty: items

app/components/list/template.hbs

+11
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
<div data-uri="{{ default _ref _self }}" class="list {{ if customIndicator 'custom-indicator' }}" data-editable="settings">
2+
<{{listType}} class="list-items">
3+
{{#each items}}
4+
<li class="list-item"><span>{{{ text }}}</span></li>
5+
{{/each}}
6+
</{{listType}}>
7+
8+
{{#if css}}
9+
<style>{{{ css }}}</style>
10+
{{/if}}
11+
</div>

app/package-lock.json

+58
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

app/package.json

+2
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,8 @@
4747
"jsonp-client": "^1.1.1",
4848
"lodash": "^4.17.5",
4949
"moment": "^2.24.0",
50+
"postcss-csso": "^3.0.0",
51+
"postcss-safe-parser": "^4.0.1",
5052
"prismjs": "^1.15.0",
5153
"speakingurl": "^14.0.1",
5254
"striptags": "^3.1.1",

app/services/universal/styles.js

+20
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
'use strict';
2+
3+
const postcss = require('postcss'),
4+
nested = require('postcss-nested'),
5+
safe = require('postcss-safe-parser'),
6+
csso = require('postcss-csso'),
7+
simpleVars = require('postcss-simple-vars');
8+
9+
/**
10+
* render scoped css using postcss
11+
* @param {string} uri uri of component
12+
* @param {string} styles custom style
13+
* @returns {string} css scoped style
14+
*/
15+
function render(uri, styles) {
16+
return postcss([nested, simpleVars, csso]).process(`[data-uri="${uri}"] { ${styles} }`, { parser: safe })
17+
.then((result) => result.css);
18+
}
19+
20+
module.exports.render = render;
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
1+
@import '_default/common/_vars.css';
2+
3+
$helvetica-full-stack: 16px / 1 Helvetica, sans-serif;
4+
$custom-indicator-red: #ec2c00;
5+
6+
.list {
7+
clear: both;
8+
font: $helvetica-full-stack;
9+
margin: 15px 0;
10+
position: relative;
11+
12+
& .list-items {
13+
counter-reset: listitem;
14+
margin: 0;
15+
}
16+
17+
& .list-item {
18+
counter-increment: listitem;
19+
padding: 0 0 5px;
20+
}
21+
22+
&.custom-indicator {
23+
clear: none;
24+
}
25+
26+
&.custom-indicator .list-items {
27+
padding: 0;
28+
}
29+
30+
&.custom-indicator .list-item {
31+
align-items: baseline;
32+
display: flex;
33+
list-style-type: none;
34+
position: relative;
35+
}
36+
37+
&.custom-indicator .list-item:before {
38+
flex: 0 0 auto;
39+
margin: 0 12px 0 22px;
40+
}
41+
42+
&.custom-indicator ul .list-item:before {
43+
background-color: $custom-indicator-red;
44+
border-radius: 50%;
45+
content: '';
46+
height: 6px;
47+
position: relative;
48+
top: -3px;
49+
width: 6px;
50+
}
51+
52+
&.custom-indicator ol .list-item:before {
53+
color: $custom-indicator-red;
54+
content: counter(listitem) '.';
55+
font-weight: 700;
56+
}
57+
}

app/styleguides/_default/components/subheader.css

+1-1
Original file line numberDiff line numberDiff line change
@@ -38,8 +38,8 @@ $helvetica-stack: Helvetica, sans-serif;
3838
opacity: 0;
3939
padding: 2px 0 0 5px;
4040
position: absolute;
41-
transition: opacity 150ms ease;
4241
-moz-transition: opacity 150ms ease;
4342
-webkit-transition: opacity 150ms ease;
43+
transition: opacity 150ms ease;
4444
}
4545
}

app/styleguides/_default/layouts/layout.css

+16-10
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ html {
5454

5555
& > .page-header,
5656
& > .top {
57-
margin: 0 auto;
57+
margin: 20px auto;
5858
width: $wrapperMaxWidth;
5959
}
6060

@@ -75,22 +75,28 @@ html {
7575
& > .bottom,
7676
& > .wrapper {
7777
padding: 0 20px;
78+
width: 600px;
7879
}
7980
}
8081
}
8182

8283
@media screen and (min-width: 768px) and (max-width: 1179.9px) {
83-
.layout > .wrapper,
84-
.layout > .bottom {
85-
padding: 0 7vw;
86-
}
84+
.layout{
85+
& > .wrapper,
86+
& > .bottom {
87+
padding: 0 7vw;
88+
}
8789

88-
.layout > .secondary > *:not(.ad) {
89-
margin: 0 7vw;
90-
}
90+
& > .top {
91+
margin: 20px 50px;
92+
}
9193

92-
.layout > .wrapper {
93-
max-width: 720px;
94+
& > .secondary > *:not(.ad) {
95+
margin: 0 7vw;
96+
}
97+
& > .wrapper {
98+
min-width: 600px;
99+
}
94100
}
95101
}
96102

0 commit comments

Comments
 (0)