git ssb

16+

Dominic / patchbay



Commit f4987c4f059ea50695536df292a96d0dc3c5af4f

accessibility: refactor the style additions

mixmix committed on 8/13/2018, 10:31:07 AM
Parent: deef6f4525d00a84b10de760ede55bf07c561630

Files changed

app/html/settings/accessibility.mcsschanged
app/html/settings/custom-styles.mcsschanged
app/page/imageSearch.mcsschanged
app/page/settings.mcsschanged
app/sync/initialise/settings.jschanged
app/sync/initialise/styles.jschanged
app/html/settings/accessibility.mcssView
@@ -20,10 +20,9 @@
2020 :focus {
2121 box-shadow: none
2222 }
2323 }
24 +
2425 i {
2526 }
2627 }
27-
2828 }
29-
app/html/settings/custom-styles.mcssView
@@ -1,5 +1,9 @@
11 CustomStyles {
2 + textarea {
3 + font-family: monospace
4 + line-height: 1.2rem
5 + }
26 button {
37 display: block
48 margin: .5rem 0
59 }
app/page/imageSearch.mcssView
@@ -1,9 +1,9 @@
11 Page -imageSearch {
22 overflow-y: auto
33
44 display: grid
5- grid-template-columns: 85vw
5 + grid-template-columns: 95vw
66 grid-template-rows: 5rem auto
77 justify-content: center
88 align-items: start
99
@@ -16,25 +16,26 @@
1616 }
1717
1818 section.results {
1919 display: flex
20 + justify-content: center
2021 align-items: center
2122 flex-wrap: wrap
2223
2324 div {
2425 cursor: pointer
2526
2627 min-width: 5rem
2728 min-height: 5rem
28- max-width: 19rem
29 + max-width: calc(95vw / 4 - 1rem)
2930 max-height: 19rem
3031
3132 display: flex
3233 justify-content: center
3334 align-items: center
3435
3536 img {
36- max-width: 19rem
37 + max-width: calc(95vw / 4 - 1rem)
3738 max-height: 19rem
3839 }
3940
4041 margin: 0 1rem 1rem 0
app/page/settings.mcssView
@@ -49,9 +49,8 @@
4949
5050 width: 600px
5151 max-width: 600px
5252 }
53-
5453 }
5554 }
5655 }
5756 }
app/sync/initialise/settings.jsView
@@ -1,6 +1,8 @@
11 const nest = require('depnest')
22 const merge = require('lodash/merge')
3 +const fs = require('fs')
4 +const { join } = require('path')
35
46 exports.gives = nest('app.sync.initialise')
57
68 exports.needs = nest({
@@ -15,9 +17,10 @@
1517 invert: false,
1618 saturation: 100,
1719 brightness: 100,
1820 contrast: 100
19- }
21 + },
22 + customStyles: defaultStyles()
2023 },
2124 filter: {
2225 exclude: {
2326 channels: ''
@@ -47,4 +50,11 @@
4750
4851 set(settings)
4952 }
5053 }
54 +
55 +function defaultStyles () {
56 + // TODO add a nice little helper README / comments
57 + const path = join(__dirname, '../../styles/mcss/app-theme-vars.mcss')
58 + const styles = fs.readFileSync(path, 'utf8')
59 + return styles
60 +}
app/sync/initialise/styles.jsView
@@ -14,19 +14,22 @@
1414 return nest('app.sync.initialise', styles)
1515
1616 function styles () {
1717 const css = values(api.styles.css()).join('\n')
18- const custom = api.settings.obs.get('patchbay.customStyles', '')
19- const accessibility = api.settings.obs.get('patchbay.accessibility', '')
18 + const custom = api.settings.obs.get('patchbay.customStyles')
19 + const accessibility = api.settings.obs.get('patchbay.accessibility')
2020
2121 document.head.appendChild(
22 + h('style', { innerHTML: css })
23 + )
24 +
25 + document.head.appendChild(
26 + h('style', { innerHTML: computed(custom, compileCss) })
27 + )
28 + document.head.appendChild(
2229 h('style', {
23- innerHTML: computed([custom, accessibility], (custom, accessibility) => {
24- return [
25- css,
26- compileCss(custom),
27- compileCss(accessibilityMcss(accessibility))
28- ].join('\n')
30 + innerHTML: computed(accessibility, a11y => {
31 + return compileCss(accessibilityMcss(a11y))
2932 })
3033 })
3134 )
3235 }
@@ -40,19 +43,25 @@
4043 const saturation = get(settings, 'saturation', 100)
4144 const brightness = get(settings, 'brightness', 100)
4245 const contrast = get(settings, 'contrast', 100)
4346
44- return `
45- body {
46- filter: ${invert ? 'invert()' : ''} saturate(${saturation}%) brightness(${brightness}%) contrast(${contrast}%)
47 + const css = `
48 +body {
49 + filter: ${invert ? 'invert()' : ''} saturate(${saturation}%) brightness(${brightness}%) contrast(${contrast}%)
4750
48- (img) {
49- filter: ${invert ? 'invert()' : ''}
50- }
51-
52- }
53- `
51 + (img) {
52 + filter: ${invert ? 'invert()' : ''}
53 + }
54 + (video) {
55 + filter: ${invert ? 'invert()' : ''}
56 + }
57 + (button) {
58 + filter: ${invert ? 'invert()' : ''}
59 + }
5460 }
61 +`
62 + return css
63 +}
5564 // ////////////////////////////
5665
5766 function values (object) {
5867 const keys = Object.keys(object)

Built with git-ssb-web