Skip to content
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

TS: Support generics for layout breakpoints #99

Open
kettanaito opened this issue Jan 28, 2019 · 4 comments
Open

TS: Support generics for layout breakpoints #99

kettanaito opened this issue Jan 28, 2019 · 4 comments
Labels
enhancement New feature or request help wanted Extra attention is needed scope:types This issue relates to TypeScript types

Comments

@kettanaito
Copy link
Owner

What:

Need to support generics to specify the relevant breakpoint names of the layout.

Why:

To have better type checking and suggestions when dealing with breakpoint-based values (<Only/> component, Layout.configure).

How:

Draft

import Layout from 'atomic-layout'

type Breakpoints = 'retina' | 'mobile' | 'desktop'

Layout<Breakpoints>.configure({...})
@kettanaito kettanaito added the enhancement New feature or request label Jan 28, 2019
@kettanaito kettanaito added this to the 1.0 milestone Jan 28, 2019
@kettanaito kettanaito added the help wanted Extra attention is needed label Jan 28, 2019
@redraushan
Copy link

Hi @kettanaito,

To have better type checking and suggestions when dealing with breakpoint-based values (<Only/> component, Layout.configure).

What kind of betterment we are looking for type checking/suggestions if I consider <Only/> component ?

At the moment, <Only/> component has following props: for, from, to, and except.
Besides except props, all props are having BreakpointRef type.

Please help me to understand the task.
Thanks

@kettanaito
Copy link
Owner Author

kettanaito commented Feb 21, 2019

Sure. Basically, you can propagate the breakpoints (strings) to such props as the Only component has. So when you type from=" you see the suggested breakpoint names:

xs
sm
md
lg
xl

Those values depend on the breakpoints you have specified in the Layout.configure(), so it may contain custom strings. This would affect any place you refer to the breakpoints.

This is possible to achieve by using generics (I had a PoC branch somewhere on local). However, I am not that strong with TypeScript, and would use some help. If it would be beneficial, I can push the PoC branch and you can follow from there.

@redraushan
Copy link

This is something new for me, reading suggestions from configuration looks really good. Could you please push your POC branch I’d love to take a look.

@kettanaito
Copy link
Owner Author

@redraushan here you go: https://github.com/kettanaito/atomic-layout/tree/99-ts-generics.

@kettanaito kettanaito added the scope:types This issue relates to TypeScript types label Mar 13, 2019
@kettanaito kettanaito removed this from the 1.0 milestone Oct 25, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request help wanted Extra attention is needed scope:types This issue relates to TypeScript types
Projects
None yet
Development

No branches or pull requests

2 participants