diff options
| author | Henry Jameson <me@hjkos.com> | 2018-06-18 12:09:14 +0300 |
|---|---|---|
| committer | Henry Jameson <me@hjkos.com> | 2018-07-06 20:12:09 +0300 |
| commit | fa8c221f3a6f9b1421e29aa014304576810a08e6 (patch) | |
| tree | 37a7f735983b6ab0e021808344ac82d9b0c2bcae /src/services/user_highlighter | |
| parent | f911182a2f608bc0589fc16210fdbc9673f6cc4e (diff) | |
moved style generator into separate file. notifications are highlighted too now.
Diffstat (limited to 'src/services/user_highlighter')
| -rw-r--r-- | src/services/user_highlighter/user_highlighter.js | 29 |
1 files changed, 29 insertions, 0 deletions
diff --git a/src/services/user_highlighter/user_highlighter.js b/src/services/user_highlighter/user_highlighter.js new file mode 100644 index 00000000..94bf2c40 --- /dev/null +++ b/src/services/user_highlighter/user_highlighter.js @@ -0,0 +1,29 @@ +import { hex2rgb } from '../color_convert/color_convert.js' +const highlightStyle = (user, store) => { + const color = store.state.config.highlight[user.screen_name] + if (!color) return + const rgb = hex2rgb(color) + const tintColor = `rgba(${Math.floor(rgb.r)}, ${Math.floor(rgb.g)}, ${Math.floor(rgb.b)}, .1)` + const tintColor2 = `rgba(${Math.floor(rgb.r)}, ${Math.floor(rgb.g)}, ${Math.floor(rgb.b)}, .2)` + return { + backgroundImage: [ + 'repeating-linear-gradient(-45deg,', + `${tintColor} ,`, + `${tintColor} 20px,`, + `${tintColor2} 20px,`, + `${tintColor2} 40px` + ].join(' '), + backgroundPosition: '0 0' + } +} + +const highlightClass = (user) => { + return 'USER____' + user.screen_name + .replace(/\./g, '_') + .replace(/@/g, '_AT_') +} + +export { + highlightClass, + highlightStyle +} |
