Comments (2)
a "main" function with html string (or whatever), css string (or whatever) as input
and then have as output, a css used ?
That is getCriticalRules
, see https://github.com/theKashey/used-styles/blob/master/__tests__/extraction.spec.tsx#LL27C18-L27C18
Examples uses loadStyleDefinitions
which is a little in between of fully automated style discoverability and "just styles", you better use parseProjectStyles
see
That would be something like
const styles = parseProjectStyles({
style: `body { padding:0 }`
});
const critical = getCriticalRules('<HTML><body>hello</body></HTML>', styles);
This code works, but TypeScript will complain
- check this example - https://github.com/theKashey/used-styles/blob/master/__tests__/simple-example.spec.tsx#L3
- just released version 2.43 contains a fix for types
from used-styles.
ok thanks :)
from used-styles.
Related Issues (20)
- Below The Fold
- Unlock selectors on discovery HOT 1
- Styles with same selector and content but different media are missing
- Usage example for CRA HOT 2
- `:not()` pseudo selector support HOT 2
- React 17 support HOT 2
- Rule filtering
- Cloudflare workers compatibility HOT 4
- React 18 (WebPack 5) doesn't work HOT 1
- missing css HOT 1
- CSS truncated incorrectly HOT 6
- renderToPipeableStream examples HOT 16
- CSS Cascade Layers support HOT 2
- moveStyles module is not exposed anymore HOT 2
- createCriticalStyleStream: problem with inserting styles into existing style tag HOT 1
- Issue with styles injected into select element HOT 7
- Update react streaming SSR example to use `renderToPipeableStream` HOT 1
- Improve and extend Examples HOT 5
- Serializable lookup table HOT 5
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from used-styles.