-
Notifications
You must be signed in to change notification settings - Fork 673
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Experimental WIP: strict-ui #719
Conversation
packages/strict-ui/src/index.ts
Outdated
@@ -4,7 +4,7 @@ import { Global } from '@emotion/core' | |||
import { scales, aliases, transforms } from './css' | |||
import sanitize from './sanitize.css' | |||
|
|||
export { Grid, ThemeProvider, useThemeUI as useStrictUI } from 'theme-ui' | |||
export { Grid, Flex, ThemeProvider, useThemeUI as useStrictUI } from 'theme-ui' |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
😎
* Licensed under the MIT License. | ||
*/ | ||
// Copied from https://cdnjs.cloudflare.com/ajax/libs/sanitize.css/2.0.0/sanitize.min.css | ||
injectGlobal` |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe there's a way to approach this reset more dynamically, rather than a blanket global style? This way you'll be able to use strict-ui
components alongside others.
So for instance in my Stack
and Inline
component, when it's rendered as an ol
or ul
I make use of a shared reset:
export const Stack: React.FC<StackProps> = ({ gap = 3, ...props }) => (
<div
{...props}
sx={{
/* …stack styles */
/* …reset returns the following: */
/* Reset: ensure direct child list-items render without bullets */
"& > li": {
listStyleType: "none",
"&:before": {
position: "absolute",
content:
'"\\200B"' /* Add zero-width space to prevent VoiceOver disable */,
},
},
}}
/>
);
Might be worth at taking a look at how @markdalgleish tackled this in Braid!
https://twitter.com/markdalgleish/status/1223161650246602752
Just a variant idea for if const inline = (gap: number) => ({
/* styles to add to the parent */
overflow: 'hidden',
alignItems: 'center',
margin: (gap / 2) * -1,
/* styles for the children */
'& > *': {
margin: gap / 2,
},
});
Then we can render elements nicely inline like so: |
Just an update: I've actually added that
Please feel free to extend upon this with your stricter type strategy! I'd be happy to help out |
Gatsby Cloud Build Report🚩 Your build failed. See the build logs here |
Going to close it for now as it was a nice experiment but would need a lot more work to be usable and I don't have the time to work on this! |
Click here for background info. This is just an experimental prototype for me to test these ideas in practice.
This is what the entire API currently looks like (essentially it's theme-ui with the restrictions outlined in the doc above and way less API surface area):
Known issues
Responsive values don't workred: 'red'
in the theme breaks the "only theme values" detectionDoesn't block shorthands (mx
,ml
) or x-y properties (marginX
)Need to set* { margin: 0; }
in resetdisplay: none
ordisplay: inline-block
?margin: auto
? Can't center anythingdisplay: list-item
and padding-inline-start accepts non-theme values