-
Notifications
You must be signed in to change notification settings - Fork 13
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
Rework Group and Inputs #2
Conversation
Deploy preview for lightspeed-flame ready! Built with commit f8f5159 |
Deploy preview for lightspeed-flame ready! Built with commit 585f4a5 |
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.
81c7113
to
27c5906
Compare
FormField is missing a README |
InputGroupAddon has the same color as bodyBg. This makes it harder to tell the layers of UI apart. Maybe consider changing that to @glambert could we have a |
Related to bodyBg, those inputs will always be in a Card tho, correct? Yes, it would be for edge-cases but we can enable it. We should write a note in the README on that as well 👍 |
@alexislightspeed so if we start putting back those |
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.
A few minor comments, otherwise very impressed by the quality of the PR.
I did my best to review carefully the component changes, a bit less on the stories.
I'm going to try the changes on local, but at least for now you can answer my questions.
Great job!! 👍
@@ -12,8 +12,8 @@ type RenderTest = { | |||
indeterminate?: boolean; | |||
id?: string; | |||
value?: string; | |||
label?: string | Function; | |||
description?: string | Function; | |||
label?: any; |
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.
string | Function | React.Element
?
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.
This is a test file so I don't think its worth 😉
borderBottomRightRadius?: string | number; | ||
} | ||
|
||
const borderRadii = system({ |
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.
Surprised this is not already part of styled-system?
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.
It is, but it's part of the border
API which also has a lot more we don't want to enable. Probably why this was created, to limit props you can change to only those needed. To be re-confirmed by @xdrdak.
import { Input } from '@lightspeed/flame/Input'; | ||
|
||
const MyComponent = () => ( | ||
<Label htmlFor="myinput" description="Some description">My Label</Label> |
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.
It misses <>
</>
to wrap this series of components.
| Prop | Type | Default | Description | | ||
| --------------- | ---------------------------- | --------- | -------------------------------------------------------------- | | ||
| `description` | `string` or `child function` | undefined | Description's text | | ||
| `html property` | `string` | undefined | Any extra properties passed will be added to the `<label>` tag | |
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.
Not sure I understand html property
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.
Any valid HTML properties such as id
, for
, etc.
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.
OK, I would add an example then, because it's not very clear.
`; | ||
|
||
const InputGroup: React.FC = ({ children, ...restProps }) => { | ||
const nextChildren = React.Children.map(children, (child: any, index) => { |
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.
any
=> React.Element
?
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.
Usually there is a good reason @xdrdak uses any
for those. I'd keep it as is and fix in a later PR.
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 sometimes it's only a text, in such case I'm not sure it's a React.Element
. But we should remove any any
in the future.
Co-Authored-By: Kevin Vicrey <[email protected]>
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.
Let's merge the MPR! 💯 💯
Description
The ever famous
Group
is about to get kicked to the curb!Group does some weird recursion thing and strange z-index shenannigans which can lead to some really funky behaviour. So, we're gonna be phasing it out in favour of the new grouping components.
On a different note, I've also tweaked the Input components to export their base components and attempted to simplify the API a bit. The old status object prop still works, but will be removed in the next major version.
InputGroup
Introducing the
InputGroup
component. Use this component to smoosh input components together (like input, select and buttons).It works by simply cloning its children and forwards the right border props. This has a few interesting quirks, namely you must keep the structure of the components flat. This also means that, as long as the components have the border props, they can get properly smooshed.
Also important to note,
InputGroup
does not manipulate anything other than border and border-radii. meaning that it will not automatically attempt to set components to have full width or whatever. This also means that trying to nest things in another component (including fragments) will result in the border properties not being applied properly. This is actually intended to reduce zany side-effects.Dropdown
component instead, which accomplishes the same thing, but has the appropriate border props applied.You can resize components by either using
flex
orwidth
props of those input components.InputGroupAddon
This component functions similarly to the old
GroupAddon
component. It's essentially a pre-styledFlex
.Input, Radio and Checkbox now export their Base Components
Each of these components export a more primitive version of themselves. This is particularly useful if you need to further customize the component, but don't really want the additional cruft that comes with these components.
Asides from some minor additional props (input prefix and suffix is still present), there's not much magic going on, meaning you are free to re-assemble your form inputs should the need presents itself. And to help you do that, we have a few more helper components inbound.
Input no longer uses objects to represent status and status message
You should no longer pass an object with magical keys to output the status and status message of a text input.
As a fun little upgrade,
statusMessage
takes a ReactNode, so feel free to customize your error message!Label and FormHelper
Label
is a new component that takes care of the needed styling and positioning of the input's description field. Use it as you would any other regular label!FormHelper
is used to display helper text or status messages. Use it in conjunction when you need to display error messages. You'll need to manually set the status of the component, since it's just a dumb pre-styled text component.RadioLabel and CheckboxLabel
Radio and Checkbox are somewhat odd ducks, in that the positioning of their description is not aligned to the actual input, but rather the label. Meaning the description is shifted slightly right to align with the label.
I've provided a RadioLabel and CheckboxLabel to get around this particular quirk. Both have the same API and styling. It's simply the name has been adjusted to match their relevant context.
How to test?
yarn dev
Checklist