Installations
npm install aphrodite-jss
Releases
Unable to fetch releases
Developer
cssinjs
Developer Guide
Module System
CommonJS
Min. Node Version
>=4.0.0
Typescript Support
No
Node Version
8.11.3
NPM Version
5.6.0
Statistics
92 Stars
47 Commits
17 Forks
8 Watching
1 Branches
59 Contributors
Updated on 18 Sept 2024
Bundle Size
45.54 kB
Minified
10.13 kB
Minified + Gzipped
Languages
JavaScript (68%)
HTML (32%)
Total Downloads
Cumulative downloads
Total Downloads
770,766
Last day
45.3%
539
Compared to previous day
Last week
-4.3%
1,662
Compared to previous week
Last month
191.4%
4,905
Compared to previous month
Last year
-51.9%
19,404
Compared to previous year
Daily Downloads
Weekly Downloads
Monthly Downloads
Yearly Downloads
Dependencies
3
Dev Dependencies
22
Aphrodite-like API on top of JSS.
This project is a merge of good ideas from aphrodite and JSS. It provides an API of aphrodite but fixes lots of limitations and caveats by using JSS as a rendering engine under the hood.
Good parts from aphrodite.
- Pretty much like inline styles known from React, except it allows to use the entire CSS.
- No CSS is generated until
css()
function invocation. Only the passed rules are converted to a CSS string and injected. - Theming is possible without any headache or framework integrations.
Benefits compared to aphrodite.
- More powerfull rendering abstraction through JSS under the hood. You are using all it's plugins and JSON DSL. To name a few:
- Children, siblings and any other kinds of selectors. (jss-nested)
- Global styles, without auto namespacing (jss-global).
- Immediate render upon
css()
call invocation. It gives you an access to computed styles right after render, no need to usesetTimeout()
. It also avoids additional recalcs and repaints, which can cause flickers and general performance overhead. - No auto "!important" insertion. You can write a plugin for this though.
Example
1import {StyleSheet, css} from 'aphrodite-jss' 2 3const sheet = StyleSheet.create({ 4 button: { 5 border: '1px solid', 6 borderRadius: 5, 7 fontSize: 'inherit', 8 lineHeight: '2.3em', 9 padding: '0 1em', 10 boxShadow: 'inset 0 1px 0 rgba(255, 255, 255, 0.1)', 11 textShadow: '0 -1px 0 rgba(0, 0, 0, 0.25)', 12 backgroundRepeat: 'repeat-x', 13 color: '#fff', 14 fontWeight: 400, 15 '& span': { 16 marginRight: 5, 17 color: '#fff' 18 } 19 }, 20 primary: { 21 borderColor: '#1177cd #0f6ab6 #0d5c9e', 22 backgroundImage: 'linear-gradient(to bottom, #2591ed 0%, #1177cd 100%)', 23 backgroundColor: '#1385e5', 24 '&:hover': { 25 backgroundImage: 'linear-gradient(to bottom, #3c9def 0%, #1385e5 100%)' 26 } 27 } 28}) 29 30document.body.innerHTML = ` 31 <button class="${css(sheet.button, sheet.primary)}"> 32 <span>✔</span>Primary 33 </button> 34`
API
Create style sheet.
StyleSheet.create(styles)
Create function doesn't render anything, it just registers your styles.
Returns an object, where key names correspond the original styles obejct.
Inject rules.
css(rule1, [rule2], [rule3], ...)
Injects a previously defined rule to the dom. This is done in sync, so the CSS rule is immediately available.
Returns a class name.
Styles format.
The format for styles is defined in jss. Aprodisiac uses jss-preset-default, so all default presets are already in place.
Customizing JSS.
aphroditeJss(jss, [options])
You can pass your own JSS instance with your custom setup.
Returns aphrodite's interface.
1import aphroditeJss from 'aphrodite-jss' 2import {create} from 'jss' 3 4const {css, StyleSheet} = aphroditeJss(create())
Serverside Rendering.
There are 2 functions you need to know - toString()
and reset()
.
As aphrodite-jss can not know that you are rendering a new response, you need to get the CSS (toString()
) when you are processing the first request and call reset()
to clean up the styles your current page has produced.
1import {toString, reset} from 'aphrodite-jss' 2 3function render() { 4 const app = renderApp() 5 const css = toString() 6 reset() 7 8 return ` 9 <head> 10 <style> 11 ${css} 12 </style> 13 <head> 14 <body> 15 ${app} 16 </body> 17 ` 18}
License
MIT
No vulnerabilities found.
Reason
no binaries found in the repo
Reason
license file detected
Details
- Info: project has a license file: LICENSE:0
- Info: FSF or OSI recognized license: MIT License: LICENSE:0
Reason
Found 5/19 approved changesets -- score normalized to 2
Reason
0 commit(s) and 0 issue activity found in the last 90 days -- score normalized to 0
Reason
no effort to earn an OpenSSF best practices badge detected
Reason
security policy file not detected
Details
- Warn: no security policy file detected
- Warn: no security file to analyze
- Warn: no security file to analyze
- Warn: no security file to analyze
Reason
project is not fuzzed
Details
- Warn: no fuzzer integrations found
Reason
SAST tool is not run on all commits -- score normalized to 0
Details
- Warn: 0 commits out of 16 are checked with a SAST tool
Reason
77 existing vulnerabilities detected
Details
- Warn: Project is vulnerable to: GHSA-6chw-6frg-f759
- Warn: Project is vulnerable to: GHSA-v88g-cgmw-v5xw
- Warn: Project is vulnerable to: GHSA-93q8-gq69-wqmw
- Warn: Project is vulnerable to: GHSA-fwr7-v2mv-hh25
- Warn: Project is vulnerable to: GHSA-67hx-6x53-jw92
- Warn: Project is vulnerable to: GHSA-cwfw-4gq5-mrqx
- Warn: Project is vulnerable to: GHSA-g95f-p29q-9xw4
- Warn: Project is vulnerable to: GHSA-grv7-fg5c-xmjg
- Warn: Project is vulnerable to: GHSA-x9w5-v3q2-3rhw
- Warn: Project is vulnerable to: GHSA-c6rq-rjc2-86v2
- Warn: Project is vulnerable to: GHSA-3xgq-45jj-v275
- Warn: Project is vulnerable to: GHSA-w573-4hg7-7wgq
- Warn: Project is vulnerable to: GHSA-vh7m-p724-62c2
- Warn: Project is vulnerable to: GHSA-r9p9-mrjm-926w
- Warn: Project is vulnerable to: GHSA-434g-2637-qmqr
- Warn: Project is vulnerable to: GHSA-49q7-c7j4-3p7m
- Warn: Project is vulnerable to: GHSA-977x-g7h5-7qgw
- Warn: Project is vulnerable to: GHSA-f7q4-pwc6-w24p
- Warn: Project is vulnerable to: GHSA-fc9h-whq2-v747
- Warn: Project is vulnerable to: GHSA-4gmj-3p3h-gm8h
- Warn: Project is vulnerable to: GHSA-8r6j-v8pm-fqw3
- Warn: Project is vulnerable to: MAL-2023-462
- Warn: Project is vulnerable to: GHSA-q42p-pg8m-cqh6
- Warn: Project is vulnerable to: GHSA-w457-6q6x-cgp9
- Warn: Project is vulnerable to: GHSA-62gr-4qp9-h98f
- Warn: Project is vulnerable to: GHSA-f52g-6jhx-586p
- Warn: Project is vulnerable to: GHSA-2cf5-4w76-r9qv
- Warn: Project is vulnerable to: GHSA-3cqr-58rm-57f8
- Warn: Project is vulnerable to: GHSA-g9r4-xpmj-mj65
- Warn: Project is vulnerable to: GHSA-q2c6-c6pm-g3gh
- Warn: Project is vulnerable to: GHSA-765h-qjxv-5f44
- Warn: Project is vulnerable to: GHSA-f2jv-r9rf-7988
- Warn: Project is vulnerable to: GHSA-43f8-2h32-f4cj
- Warn: Project is vulnerable to: GHSA-qqgx-2p2h-9c37
- Warn: Project is vulnerable to: GHSA-2pr6-76vf-7546
- Warn: Project is vulnerable to: GHSA-8j8c-7jfh-h6hx
- Warn: Project is vulnerable to: GHSA-896r-f27r-55mw
- Warn: Project is vulnerable to: GHSA-9c47-m6qq-7p4h
- Warn: Project is vulnerable to: GHSA-282f-qqgm-c34q
- Warn: Project is vulnerable to: GHSA-6c8f-qphg-qjgp
- Warn: Project is vulnerable to: GHSA-76p3-8jx3-jpfq
- Warn: Project is vulnerable to: GHSA-3rfm-jhwj-7488
- Warn: Project is vulnerable to: GHSA-hhq3-ff78-jv3g
- Warn: Project is vulnerable to: GHSA-4xc9-xhrj-v574
- Warn: Project is vulnerable to: GHSA-x5rq-j2xg-h7qm
- Warn: Project is vulnerable to: GHSA-jf85-cpcp-j695
- Warn: Project is vulnerable to: GHSA-p6mc-m468-83gw
- Warn: Project is vulnerable to: GHSA-29mw-wpgm-hmr9
- Warn: Project is vulnerable to: GHSA-35jh-r3h4-6jhm
- Warn: Project is vulnerable to: GHSA-4xcv-9jjx-gfj3
- Warn: Project is vulnerable to: GHSA-f9cm-qmx5-m98h
- Warn: Project is vulnerable to: GHSA-7wpw-2hjm-89gp
- Warn: Project is vulnerable to: GHSA-952p-6rrq-rcjv
- Warn: Project is vulnerable to: GHSA-f8q6-p94x-37v3
- Warn: Project is vulnerable to: GHSA-vh95-rmgr-6w4m / GHSA-xvch-5gv4-984h
- Warn: Project is vulnerable to: GHSA-fhjf-83wg-r2j9
- Warn: Project is vulnerable to: GHSA-5fw9-fq32-wv5p
- Warn: Project is vulnerable to: GHSA-hj48-42vr-x3v9
- Warn: Project is vulnerable to: GHSA-hrpp-h998-j3pp
- Warn: Project is vulnerable to: GHSA-p8p7-x288-28g6
- Warn: Project is vulnerable to: GHSA-c2qf-rxjj-qqgw
- Warn: Project is vulnerable to: GHSA-4g88-fppr-53pp
- Warn: Project is vulnerable to: GHSA-4jqc-8m5r-9rpr
- Warn: Project is vulnerable to: GHSA-4rq4-32rv-6wp6
- Warn: Project is vulnerable to: GHSA-64g7-mvw6-v9qj
- Warn: Project is vulnerable to: GHSA-j44m-qm6p-hp7m
- Warn: Project is vulnerable to: GHSA-3jfq-g458-7qm9
- Warn: Project is vulnerable to: GHSA-r628-mhmh-qjhw
- Warn: Project is vulnerable to: GHSA-9r2w-394v-53qc
- Warn: Project is vulnerable to: GHSA-5955-9wpr-37jh
- Warn: Project is vulnerable to: GHSA-qq89-hq3f-393p
- Warn: Project is vulnerable to: GHSA-f5x3-32g6-xq36
- Warn: Project is vulnerable to: GHSA-jgrx-mgxx-jf9v
- Warn: Project is vulnerable to: GHSA-72xf-g2v4-qvf3
- Warn: Project is vulnerable to: GHSA-3h5v-q93c-6h6q
- Warn: Project is vulnerable to: GHSA-c4w7-xm78-47vh
- Warn: Project is vulnerable to: GHSA-p9pc-299p-vxgp
Score
2.3
/10
Last Scanned on 2024-11-25
The Open Source Security Foundation is a cross-industry collaboration to improve the security of open source software (OSS). The Scorecard provides security health metrics for open source projects.
Learn More