Skip to content
This repository was archived by the owner on Jan 20, 2022. It is now read-only.

feat(Input): add new component#64

Merged
alinais merged 13 commits intomasterfrom
feature/input-component
Jul 17, 2018
Merged

feat(Input): add new component#64
alinais merged 13 commits intomasterfrom
feature/input-component

Conversation

@alinais
Copy link
Collaborator

@alinais alinais commented Jul 9, 2018

Input

A standard input field.

TODO

  • Conformance test
  • Minimal doc site example
  • Stardust base theme
  • Teams Light theme
  • Teams Dark theme
  • Teams Contrast theme
  • W3 accessibility check
  • Stardust accessibility check
  • Update glossary props table

API Proposal

Default input component

(contains only the placeholder)
image

The placeholder is a property that can be added to an input.

<Input placeholder="Search ..." />

will output

<div placeholder="Search..." as="div" type="text" class="ui-input">
  <input type="text" placeholder="Search..." />
</div>

Input with an icon

An input in a search component can have a search icon.

<Input icon="search" placeholder="Search..." />

will output

<div icon="search" placeholder="Search..." as="div" type="text" class="ui-input">
  <input type="text" placeholder="Search..." />
  <i class="ui-icon"></i>
</div>

image

@codecov
Copy link

codecov bot commented Jul 9, 2018

Codecov Report

Merging #64 into master will increase coverage by 0.67%.
The diff coverage is 86.95%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master      #64      +/-   ##
==========================================
+ Coverage   69.72%   70.39%   +0.67%     
==========================================
  Files          70       73       +3     
  Lines        1133     1179      +46     
  Branches      215      222       +7     
==========================================
+ Hits          790      830      +40     
- Misses        338      344       +6     
  Partials        5        5
Impacted Files Coverage Δ
src/components/Icon/fontAwesomeIconRules.ts 20% <ø> (ø) ⬆️
src/components/Input/inputRules.ts 100% <100%> (ø)
src/components/Input/inputVariables.ts 100% <100%> (ø)
src/components/Input/Input.tsx 81.81% <81.81%> (ø)

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 655be85...7467269. Read the comment docs.

</Menu.Item>
<Menu.Item active>
<Input
<SemanticUIInput
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This would be a great place to dog food our own new Input component!

I think Stardust's first Input iteration will support everything that is needed here, except icon. The styling won't look quite as nice until we introduce inverted and fluid, but that is ok. It will serve as a reminder to us.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

will add in a different PR

focus: PropTypes.bool,

/** Optional Icon to display inside the Input. */
icon: PropTypes.oneOfType([PropTypes.bool, customPropTypes.itemShorthand]),
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I know this is still being worked on. Just a reminder to trim it down to the minimal implementation for the first PR.

@alinais alinais changed the title WIP - Feature/input component feat(Input): add new component Jul 12, 2018
@alinais alinais force-pushed the feature/input-component branch from 82b540d to b6451cb Compare July 12, 2018 16:50
@alinais alinais force-pushed the feature/input-component branch from 97e3378 to 0aed4ac Compare July 16, 2018 17:10

icon: ({ props, variables }) => {
return {
position: 'absolute',
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not sure if you're looking for css feedback here (or if this is just a first-pass for controls), but can we change this to use flexbox? I think we could replace most of the styles with something like this:
display: inline-flex;
align-items: center;
justify-content: flex-end;

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@notandrew this is a first implementation for this component. But I am updating the rules to a more simple approach. Thanks for your advice. Please check the updates.

mnajdova
mnajdova previously approved these changes Jul 17, 2018
border: variables.defaultBorder,
borderRadius: variables.borderRadius,
outline: 0,
padding: `${pxToRem(6)} 0 ${pxToRem(6)} ${pxToRem(10)}`,
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would introduce the padding value as a variable as well, so that the users of the component can override it if they want.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can you expand on that @mnajdova ? why isn't it possible using the regular style object? what would be the expected API for a user that wants to set his own padding? some examples would be great

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So, if I am user of the Input component, if the padding is provided as variable, I could use:

<Input variables={{padding: '0px'}} />

and this would override the default defined padding. There is example of this in the Avatar component, regarding using the Label component.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@mnajdova

I was hitting this today, I didn't understand why my styles were overwritten, it's kind of strange that we have to do it like this; if I'm not wrong, we have 2 or 3 ways of passing styling to components:

  • using className prop, which is the most obvious one and I think should be used; however it's not reliable because if a certain CSS property is defined in the rules of a component it cannot be overwritten by classes passed using className;
  • using variables prop in order to override variables that we pass to the rules;
  • using styles native prop?

What's the benefit of introducing this behavior (using variables) to using styles native prop?

@alinais alinais merged commit 22fc624 into master Jul 17, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants