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
[jss] Support simple (e.g. "&:hover") pseudo-selectors of jss-nested. #24862
Comments
If anyone goes after this, you may want to also think about nested media-queries in the same syntactic position. These are considerably harder to come up with a reasonable solution for, because there is no hope of a library-provided lexicon of likely keys; the developer must declare, or provide some way to infer, the keys that they are using. I ended up with this, which is definitely lame but may help seed thought: export type CSSDeclBlock<ODDKEYS extends string = never> =
CSS.Properties<string | number> & {[key in Pseudos]?:CSS.Properties<string | number>} & {[key in ODDKEYS]?:CSS.Properties<string | number>}
//=== used as:
// Force string-constant typing.
// Consider use of a string enum;
// see https://basarat.gitbooks.io/typescript/docs/types/literal-types.html
const mqSmallWindow: '@media (max-width: 1280px) and (max-height: 1024px)' =
'@media (max-width: 1280px) and (max-height: 1024px)'
const mqNotSmallWindow: '@media (min-width: 1281px), (min-height: 1025px)' =
'@media (min-width: 1281px), (min-height: 1025px)'
export type UsedMediaQueries = typeof mqSmallWindow | typeof mqNotSmallWindow
type MyCSSBlock = CSSDeclBlock<UsedMediaQueries> |
The issue here is with Material UI, not |
Hi thread, we're moving DefinitelyTyped to use GitHub Discussions for conversations the To help with the transition, we're closing all issues which haven't had activity in the last 6 months, which includes this issue. If you think closing this issue is a mistake, please pop into the TypeScript Community Discord and mention the issue in the |
Consider support for simple jss-nested pseudo-selectors like &:hover, which I suspect are the overwhelming majority of pseudo-selector use in jss. csstype has pseudoselectors, but of course they are without the leading ampersand, which is a trigger for jss-nested.
Support might look like the attached pseudos.ts, together with a definition or two at some level leveraging those, e.g. roughly
It might make sense to try to get the pseudos.ts definitions into
csstype
, but probably only as a separate, standalone file.The text was updated successfully, but these errors were encountered: