-
Notifications
You must be signed in to change notification settings - Fork 83
feat(FluidGrid): implement material-ui inspired grid #114
base: master
Are you sure you want to change the base?
Conversation
This pull request is being automatically deployed with Vercel (learn more). 🔍 Inspect: https://vercel.com/thecomputerm/svelte-materialify/arhniw0fc |
a0d5766
to
e10894b
Compare
(unofficial reviewer here, says code+feature is good) |
Can you specify the difference between FluidGrid and the other Grid system in the description? |
Yes. the documentation has to be fleshed out some more. |
/** sets alignment of grid items */ | ||
alignItems?: 'start' | 'center' | 'end' | 'stretch' | 'baseline'; | ||
/** sets column size at xs-breakpoint */ | ||
xs?: number | boolean; |
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.
I'm unsure about the number | boolean
types.
actually the number
only accepts a certain range (1 through $grid-columns
).
and the boolean
only accepts true
.
can that be expressed somehow? I'm new to typescript ;)
|
||
interface FluidGridProps { | ||
/** whether this is a container */ | ||
container?: boolean; |
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.
at least one of container
or item
has to be set to true.
can that be expressed somehow ?
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.
You can use discriminated unions/algebraic data types when you want to declare mutually exclusive states.
interface FluidGridSharedProps {
// all common props go here
}
interface FluidGridContainerProps extends FluidGridSharedProps {
container: true;
item?: false;
}
interface FluidGridItemProps extends FluidGridSharedProps {
item: true;
container?: false;
}
type FluidGridProps = FluidGridContainerProps | FluidGridItemProps
Be aware that as a union type rather than an interface there are more limitations placed on FluidGridProps
so this approach has drawbacks to consider. One such drawback is that you cannot extend it with a new child interface:
interface MyCustomGridProps extends FluidGridProps {
foo: string;
}
^^^ this will throw a compiler error
Instead you must declare a child as a type instead
type MyCustomGridProps = FluidGridProps & {
foo: string
}
^^^ this will compile
I haven't reviewed much of the code base to check if this approach is being used for this project but hopefully this answers your question.
display: flex; | ||
align-items: center; | ||
justify-content: center; | ||
height: 100%; |
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.
I'm unsure of height: 100%
(and maybe align-items: center
) has to go into FluidGrid.scss
for stretch
to work properly.
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.
I don't see any difference without it, also it would be an easy change if someone has problems with it :)
<Slider bind:value={values[label]}>{label}</Slider> | ||
<Slider | ||
bind:value={values[label]} | ||
min={controls[label].min || 0} |
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.
these newly added settings duplicate the defaults of Slider
which feels wrong as they might diverge.
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.
works for now, or what would you do instead? 😄
97f53c3
to
9d31eb0
Compare
marked this PR as draft until I'm done :) |
i just pushed a separate commit that removes the requirement of using |
any update on this PR ? |
first of thanks for this great package.
I added a grid that is inspired by reacts material-ui.