johanneslumpe / styled-props Goto Github PK
View Code? Open in Web Editor NEWTyped prop styling for react components
License: MIT License
Typed prop styling for react components
License: MIT License
When defining media queries due to using Object.keys
on the passed-in media query object, the resulting media queries can appear out of order. Instead of using the keys from the passed-in object we should use Object.keys
on theme.breakpoints
and then cache the resulting value and re-use it across all function calls.
Certain css rules allow arbitrary values, e.g. length values: 10px
, 10%
, calc()
etc. Since these can only be typed as string
in TypeScript, to still provide auto-completion for all other values, we should allow interfaces to define multiple props, each with their own types, e.g.:
interface IVerticalAlignProps {
verticalAlign: 'baseline' | 'sub' | 'super' | 'text-top' | 'text-bottom' | 'middle' | 'top' | 'bottom';
verticalAlignRaw: string;
};
This allows users to define props in a way that still gives them the required auto-completions for basic values, but allows for custom string value as well. Additionally it makes it easy to grep for usages of *Raw
to audit a code base for invalid/unnecessary usages of these "arbitrary" values.
We should use https://github.com/mdn/data/blob/master/css/definitions.json to group helper functions together in sub directories instead of throwing all of them into the main index file.
If props are not prefixed, it becomes harder to distinguish between a component-level prop and a style-prop. It also makes it fairly involved to grep for style-prop usage across an app. By always prefixing all interface values with $
, we can create an easy to follow convention which will minimize prop collisions and facilitate discoverability via Intellisense.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.