Skip to content

Commit faff35d

Browse files
authored
feat (stacks: autoresize) configurable flag to autoresize to push purposes below fold / tighten styles to reduce required size (#46)
* feat (stacks: autoresize) configurable flag to autoresize to push purposes below fold / tighten styles to reduce required size * add to reference page
1 parent 9c780d6 commit faff35d

File tree

12 files changed

+245
-80
lines changed

12 files changed

+245
-80
lines changed

CHANGELOG.md

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,12 @@
1+
## [2.0.4](https://github.com/openmail/system1-cmp/compare/v2.0.3...v2.0.4) (2020-09-17)
2+
3+
### Styling
4+
5+
- [x] Downsize fonts and spacing mobile
6+
- [x] Downsize spacing desktop
7+
- [x] Add scroll bar
8+
- [x] Auto-position CMP vertically based on purposes
9+
110
## [2.0.3](https://github.com/openmail/system1-cmp/compare/v2.0.2...v2.0.3) (2020-09-15)
211

312
### Fix

README.md

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@ TCF 2.0 Consent Management Platform (CMP) UI tool. We are in the process of vali
99
<!-- START doctoc generated TOC please keep comment here to allow auto update -->
1010
<!-- DON'T EDIT THIS SECTION, INSTEAD RE-RUN doctoc TO UPDATE -->
1111

12-
1312
- [Installation / Use](#installation--use)
1413
- [API](#api)
1514
- [Customized API](#customized-api)
@@ -64,6 +63,8 @@ API signatures have changed from the CMP TCF 1.1, but we've tried to keep the co
6463
boxShadow: 'none',
6564
secondaryColor: '#869cc0',
6665
featuresColor: '#d0d3d7',
66+
shouldAutoResizeModal: true, // resizes modal on stacks screen to push stacks below fold
67+
maxHeightModal: '40vh',
6768
},
6869
ccpaApplies: true,
6970
gdprApplies: true,
@@ -175,6 +176,7 @@ Set configuration for your CMP during the `init` phase.
175176
__tcfapi('init', 2, () => {}, {
176177
theme: {
177178
maxHeightModal: '50vh',
179+
shouldAutoResizeModal: true,
178180
primaryColor: '#0099ff',
179181
},
180182
canLog: true, // pixel logging for monitoring and alerting
@@ -210,6 +212,8 @@ Override styling choices using the following properties:
210212
- `textLinkColor`: '#0099ff'
211213
- `secondaryColor`: '#869cc0'
212214
- `featuresColor`: '#d0d3d7'
215+
- `maxHeightModal`: '40vh' // 40vh by default; enforce a maxheight as a %,px,vh
216+
- `shouldAutoResizeModal`: true // false by default; auto resize modal on stacks screen to push purposes below fold. Works in conjunction with `maxHeightModal`
213217

214218
## Initialize from URL Param
215219

package.json

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "system1-cmp",
3-
"version": "2.0.3",
3+
"version": "2.0.4",
44
"description": "System1 Consent Management Platform for TCF 1.1 GDPR Compliance",
55
"scripts": {
66
"clean": "rimraf ./dist",
@@ -13,10 +13,11 @@
1313
"deploy": "yarn clean && yarn deploy:original && yarn deploy:s1",
1414
"build:original": "cross-env NODE_ENV=production webpack --progress --config config/webpack.config.babel.js",
1515
"deploy:original": "yarn build:original && yarn upload:original",
16-
"upload:original": "cross-var s3-deploy './dist/{*.?(js|html),docs/**}' --cwd './dist' --region us-west-2 --bucket s1-layout-cdn/cmp --gzip --cache 1440 --distId E5JQ1CRXXPTKM --invalidate '/cmp/*.js /cmp/* /cmp/docs/*'",
16+
"upload:original": "cross-var s3-deploy './dist/{*.?(js|html),docs/**}' --cwd './dist' --region us-west-2 --bucket s1-layout-cdn/cmp --gzip html,js,css,json --cache 1440 --distId E5JQ1CRXXPTKM --invalidate '/cmp/*.js /cmp/* /cmp/docs/*'",
1717
"build:s1": "cross-env NODE_ENV=production webpack --progress --config config/s1.webpack.config.babel.js",
1818
"deploy:s1": "yarn build:s1 && yarn upload:s1",
19-
"upload:s1": "cross-var s3-deploy './dist/$npm_package_version/**' --cwd './dist/$npm_package_version' --region us-west-2 --bucket s1-layout-cdn/cmp/$npm_package_version --gzip --preventUpdates --immutable",
19+
"upload:s1": "cross-var s3-deploy './dist/$npm_package_version/**' --cwd './dist/$npm_package_version' --region us-west-2 --bucket s1-layout-cdn/cmp/$npm_package_version --gzip html,js,css,json --preventUpdates --cache 604800 --distId E5JQ1CRXXPTKM --invalidate '/cmp/$npm_package_version/*",
20+
"upload:s1:again": "cross-var s3-deploy './dist/$npm_package_version/**' --cwd './dist/$npm_package_version' --region us-west-2 --bucket s1-layout-cdn/cmp/$npm_package_version --gzip html,js,css,json --cache 604800 --distId E5JQ1CRXXPTKM --invalidate '/cmp/$npm_package_version/*'",
2021
"deploy:test": "yarn build:s1 && yarn upload:test",
2122
"upload:test": "cross-var s3-deploy './dist/$npm_package_version/**' --cwd './dist/$npm_package_version' --region us-west-2 --bucket s1-layout-cdn/cmp/test --gzip --cache 1440 --distId E5JQ1CRXXPTKM --invalidate '/cmp/test/* /cmp/test/*.html'",
2223
"prebuild": "npm run clean && mkdirp dist",
@@ -115,6 +116,7 @@
115116
"handlebars-loader": "^1.7.1",
116117
"js-beautify": "^1.7.5",
117118
"lodash": "^4.17.11",
119+
"lodash.debounce": "^4.0.8",
118120
"no-case": "^3.0.3",
119121
"preact": "^8.4.2",
120122
"preact-compat": "^3.18.4",

src/s1/components/app.jsx

Lines changed: 37 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,17 @@ export default class App extends Component {
1313
state = {
1414
store: this.props.store,
1515
shouldShowModal: false,
16+
maxHeightModal: 0,
17+
};
18+
19+
handleMaxHeightChange = (newMaxHeightModal) => {
20+
const { maxHeightModal } = this.state;
21+
if (typeof maxHeightModal !== 'string') {
22+
// once we switch to %/vh based max-height, keep it
23+
this.setState({
24+
maxHeightModal: newMaxHeightModal,
25+
});
26+
}
1627
};
1728

1829
updateState(store) {
@@ -25,6 +36,13 @@ export default class App extends Component {
2536

2637
componentDidMount() {
2738
const { store } = this.props;
39+
const {
40+
config: { theme },
41+
} = store;
42+
const { shouldAutoResizeModal, maxHeightModal } = theme;
43+
if (!shouldAutoResizeModal) {
44+
this.handleMaxHeightChange(maxHeightModal);
45+
}
2846
store.subscribe(this.updateState.bind(this));
2947
setTimeout(this.componentDidUpdate.bind(this), 100); // delay reveal on first load
3048
}
@@ -42,23 +60,38 @@ export default class App extends Component {
4260
}
4361

4462
render(props, state) {
45-
const { store, shouldShowModal } = state;
63+
const { store, shouldShowModal, maxHeightModal } = state;
4664
const { tcModel } = store;
4765
const { consentScreen } = tcModel;
4866

4967
return (
5068
<div class={style.gdpr}>
5169
{!consentScreen ||
5270
(consentScreen === CONSENT_SCREENS.STACKS_LAYER1 && (
53-
<BannerStacks store={store} isShowing={shouldShowModal && tcModel} />
71+
<BannerStacks
72+
store={store}
73+
isShowing={shouldShowModal && tcModel}
74+
maxHeightModal={maxHeightModal}
75+
onMaxHeightChange={this.handleMaxHeightChange}
76+
/>
5477
))}
5578

5679
{consentScreen === CONSENT_SCREENS.PURPOSES_LAYER2 && (
57-
<BannerPurposes store={store} isShowing={shouldShowModal && tcModel} />
80+
<BannerPurposes
81+
store={store}
82+
isShowing={shouldShowModal && tcModel}
83+
maxHeightModal={maxHeightModal}
84+
onMaxHeightChange={this.handleMaxHeightChange}
85+
/>
5886
)}
5987

6088
{consentScreen === CONSENT_SCREENS.VENDORS_LAYER3 && (
61-
<BannerVendors store={store} isShowing={shouldShowModal && tcModel} />
89+
<BannerVendors
90+
store={store}
91+
isShowing={shouldShowModal && tcModel}
92+
maxHeightModal={maxHeightModal}
93+
onMaxHeightChange={this.handleMaxHeightChange}
94+
/>
6295
)}
6396
</div>
6497
);

src/s1/components/app.less

Lines changed: 27 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,17 +25,42 @@
2525
margin: 0;
2626
}
2727

28-
input:not([type]), input[type="text"], input[type="password"] {
28+
input:not([type]),
29+
input[type='text'],
30+
input[type='password'] {
2931
box-sizing: border-box;
3032
box-shadow: 0 3px 3px rgba(0, 0, 0, 0.05) inset;
3133
background-color: #fff;
3234
border-radius: 4px;
3335
border: 1px solid #c5c5c5;
3436
color: #333;
35-
font-family: "Helvetica Neue", Helvetica, Arial, sans-serif;
37+
font-family: 'Helvetica Neue', Helvetica, Arial, sans-serif;
3638
font-size: 1em;
3739
margin: 0;
3840
padding: 0 9px;
3941
height: 28px;
4042
}
43+
44+
::-webkit-scrollbar {
45+
-webkit-appearance: none;
46+
}
47+
48+
::-webkit-scrollbar:vertical {
49+
width: 11px;
50+
}
51+
52+
::-webkit-scrollbar:horizontal {
53+
height: 11px;
54+
}
55+
56+
::-webkit-scrollbar-thumb {
57+
border-radius: 8px;
58+
border: 2px solid white; /* should match background, can't be transparent */
59+
background-color: rgba(0, 0, 0, 0.5);
60+
}
61+
62+
::-webkit-scrollbar-track {
63+
background-color: rgba(0, 0, 0, 0.02);
64+
border-radius: 8px;
65+
}
4166
}

src/s1/components/banner/banner.less

Lines changed: 23 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -10,12 +10,14 @@
1010
right: 0;
1111
left: 0;
1212
bottom: 0;
13+
padding-top: 25px;
14+
padding-right: 15px;
15+
padding-left: 30px;
1316
z-index: 99999;
1417
color: @color-textLight;
1518
background: white;
1619
font-size: 16px;
1720
transition: transform 350ms ease-in-out, opacity 350ms linear;
18-
padding-right: 10px;
1921
box-shadow: 0 -1px 1px rgba(0, 0, 0, 0.12), 0 -2px 2px rgba(0, 0, 0, 0.12), 0 -4px 4px rgba(0, 0, 0, 0.12),
2022
0 -8px 8px rgba(0, 0, 0, 0.12), 0 -16px 16px rgba(0, 0, 0, 0.12);
2123
border-top-left-radius: 25px;
@@ -80,8 +82,12 @@
8082
.content {
8183
max-height: 60vh;
8284
overflow: auto;
83-
padding: 20px 30px;
85+
padding-top: 0px;
86+
padding-left: 0px;
87+
padding-right: 20px;
88+
padding-bottom: 0px;
8489
-webkit-overflow-scrolling: touch;
90+
transition: max-height 350ms ease-in-out;
8591

8692
@media @smartphone {
8793
padding: 0px 5px;
@@ -97,42 +103,47 @@
97103

98104
@media @smartphone {
99105
font-size: 12px;
100-
line-height: 20px;
106+
line-height: 18px;
101107
}
102108

103109
.title {
104110
font-size: 32px;
105111
font-weight: bold;
106112
color: @color-text;
107-
padding: 15px 0;
113+
padding: 5px 0;
108114
margin-bottom: 10px;
109115
line-height: 32px;
110116

111117
@media @smartphone {
112-
font-size: 28px;
113-
line-height: 28px;
118+
font-size: 22px;
119+
line-height: 22px;
114120
font-weight: bold;
121+
padding: 5px 0;
122+
margin-bottom: 5px;
115123
}
116124
}
117125
}
118126

119127
.consent {
120128
flex-basis: 100%;
121129
text-align: left;
122-
margin-top: 30px;
123-
margin-bottom: 30px;
130+
margin-top: 20px;
131+
padding-bottom: 20px;
132+
margin-bottom: 10px;
124133
font-size: 20px;
125134
display: flex;
126135

127136
@media @smartphone {
128137
display: flex; /* primary flex container */
129138
flex-direction: row; /* horizontal alignment of flex items (default value; can be omitted) */
130139
align-items: stretch; /* will apply equal heights to flex items (default value; can be omitted) */
131-
font-size: 1em;
132-
line-height: 1.2em;
140+
font-size: 12px;
141+
line-height: 12px;
133142
text-align: center;
134-
margin-top: 20px;
135-
margin-bottom: 20px;
143+
padding-top: 15px;
144+
padding-bottom: 10px;
145+
margin-top: 0;
146+
margin-bottom: 10px;
136147
}
137148

138149
a {

0 commit comments

Comments
 (0)