Security News
tea.xyz Spam Plagues npm and RubyGems Package Registries
Tea.xyz, a crypto project aimed at rewarding open source contributions, is once again facing backlash due to an influx of spam packages flooding public package registries.
stylebuddy
Advanced tools
Readme
Generate CSS from JSON without any additional dependencies:
media queries
:hover
, :focus
, :before
, etc.body,
, .components
, #component
)-webkit-transition
, display: -moz-box
, etc.npm install --save stylebuddy
import stylebuddy from 'stylebuddy';
const desktop = '@media screen and (min-width:720px)';
const input = {
component: {
background: '#ccc',
':hover': {
background: '#777'
},
[desktop]: {
fontSize: 20,
':hover': {
background: '#333'
}
}
}
};
const styleSheet = stylebuddy.create();
const styles = styleSheet.add(input);
const css = styleSheet.render();
// ._component_2513881194{background:#ccc;}.component_2513881194:hover ...
const styleNode = document.createElement('style');
document.head.appendChild(styleNode);
domNode.textContent = css;
console.log(styles.component);
// ._component_2513881194
create([, config])
Returns a new instance of the styleSheet API. The optional config merges with the default values and will be used for the current styleSheet instance.
styleSheet.add(styles[, config])
Returns an object with the generated style identifiers. The passed config will be merged with the styleSheet config.
styleSheet.render()
Returns the CSS string of the current styleSheet instance.
const DEFAULT_CONFIG = {
prefix: '.', // e.g.: enforce css classes
delimiter: '_',
salt: '',
hashSelector: false,
appendHash: true,
};
import stylebuddy from 'stylebuddy';
const styleSheetConfig = {
delimiter: '___',
appendHash: false
};
const styles = {
components: {
background: '#ccc'
}
};
const styleSheet = stylebuddy.create(styleSheetConfig);
styleSheet.add(styles);
const css = styleSheet.render();
// .___components{background:#ccc;}
import stylebuddy from 'stylebuddy';
const tagSelector = {
body: {
background: '#ccc'
}
};
const styleSheet = stylebuddy.create();
styleSheet.add(tagSelector, { delimiter: '', prefix: '', appendHash: false });
const css = styleSheet.render();
// body{background:#ccc;}
import stylebuddy from 'stylebuddy';
const idSelector = {
component: {
background: '#333'
}
};
const styleSheet = stylebuddy.create();
styleSheet.add(idSelector, { prefix: '#', appendHash: false });
const css = styleSheet.render();
// #_component{background:#333;}
import stylebuddy from 'stylebuddy';
const input = {
component: {
WebkitTransition: '200ms all linear',
display: ['-webkit-box', '-moz-box']
}
};
const styleSheet = stylebuddy.create();
const styles = styleSheet.add(input);
const css = styleSheet.render();
// ._component_2513881194{-webkit-transition:200ms all linear;display:-webkit-box;display:-moz-box;}
import stylebuddy from 'stylebuddy';
const tagSelectors = {
body: {
background: '#ccc'
}
};
const classSelectors = {
components: {
background: '#999'
}
};
const idSelectors = {
component: {
background: '#333'
}
};
const styleSheetConfig = {
appendHash: false
};
const styleSheet = stylebuddy.create(styleSheetConfig);
styleSheet.add(tagSelectors, { prefix: '', delimiter: '' });
styleSheet.add(classSelectors, { delimiter: '___' });
styleSheet.add(idSelectors, { prefix: '#' });
const css = styleSheet.render();
// body{background:#ccc;}.___components{background:#999;}#_component{background:#333;}
const styleNode = document.createElement('style');
document.head.appendChild(styleNode);
domNode.textContent = css;
FAQs
Generate encapsulated css inline styles which are extremely configurable
The npm package stylebuddy receives a total of 15 weekly downloads. As such, stylebuddy popularity was classified as not popular.
We found that stylebuddy demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
Tea.xyz, a crypto project aimed at rewarding open source contributions, is once again facing backlash due to an influx of spam packages flooding public package registries.
Security News
As cyber threats become more autonomous, AI-powered defenses are crucial for businesses to stay ahead of attackers who can exploit software vulnerabilities at scale.
Security News
UnitedHealth Group disclosed that the ransomware attack on Change Healthcare compromised protected health information for millions in the U.S., with estimated costs to the company expected to reach $1 billion.