Skip to content
This repository has been archived by the owner on Mar 4, 2020. It is now read-only.

fix(Input): changing the default styles for Input component #25

Closed

Conversation

alinais
Copy link
Contributor

@alinais alinais commented Jul 30, 2018

Input

Updating the default classes for the input to match the light view of the Teams UI.

TODO

  • Conformance test
  • Minimal doc site example
  • Stardust base theme
  • Teams Light theme
  • Teams Dark theme
  • Teams Contrast theme
  • Confirm RTL usage
  • W3 accessibility check
  • Stardust accessibility check
  • Update glossary props table
  • Update the CHANGELOG.md

UI Update

Simple input
image

Simple input focused
image

Input variation with icon
image

@codecov
Copy link

codecov bot commented Jul 30, 2018

Codecov Report

Merging #25 into master will decrease coverage by 0.24%.
The diff coverage is 74.07%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master      #25      +/-   ##
==========================================
- Coverage   87.37%   87.12%   -0.25%     
==========================================
  Files          74       74              
  Lines        1125     1142      +17     
  Branches      200      202       +2     
==========================================
+ Hits          983      995      +12     
- Misses        138      143       +5     
  Partials        4        4
Impacted Files Coverage Δ
src/components/Input/inputRules.ts 100% <100%> (ø) ⬆️
src/themes/teams/siteVariables.ts 100% <100%> (ø) ⬆️
src/components/Input/inputVariables.ts 100% <100%> (ø) ⬆️
src/components/Input/Input.tsx 78% <46.15%> (-7.72%) ⬇️

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 7b43139...598c63e. Read the comment docs.

@codepretty
Copy link
Collaborator

codepretty commented Jul 30, 2018

Looks like the bottom focus border angle is inverted.

It should be angled up at the corners, like this...
image

@@ -9,13 +9,22 @@ const inputRules = {
borderRadius: variables.borderRadius,
outline: 0,
padding: variables.defaultPadding,
backgroundColor: variables.backgroundColor,
':focus-within': {
Copy link
Collaborator

Choose a reason for hiding this comment

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

:focus-within isn't supported in IE/Edge

Copy link
Contributor Author

@alinais alinais Jul 31, 2018

Choose a reason for hiding this comment

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

@codepretty, thanks for the help. I changed the approach to move input at the full size of the parent div and basically the focus will stay attached to the input, in a classic way that works in Edge

@codepretty
Copy link
Collaborator

When I click on the search icon, the input doesn't get focused.

@alinais alinais force-pushed the feature/input-component-base-theme-light-teams branch from fc18596 to 60739ac Compare August 6, 2018 13:56
renderComponent({ ElementType, classes, rest }) {
const { children, className, icon, input, type } = this.props
const [htmlInputProps, restProps] = this.partitionProps()

const inputClasses = cx(classes.input)
const iconClasses = cx(classes.icon)
Copy link
Contributor

@mnajdova mnajdova Aug 6, 2018

Choose a reason for hiding this comment

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

No need for using cx here, as the classes are already calculated and we are not combining multiple object to classes.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

fixed

@@ -108,9 +126,15 @@ class Input extends UIComponent<any, any> {
<ElementType {...rest} className={classes.root} {...htmlInputProps}>
{createHTMLInput(input || type, {
defaultProps: htmlInputProps,
Copy link
Contributor

Choose a reason for hiding this comment

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

We can extract the creation of the input in a separate variable and reuse it in the both return statements. I would actually refactor this with the following:

return (<ElementType {...rest} className={classes.root} {...htmlInputProps}>
          {createHTMLInput(input || type, {
            defaultProps: htmlInputProps,
            overrideProps: {
              className: inputClasses,
              ref: this.handleInputRef,
            },
          })}
          {this.computeIcon() && Icon.create(this.computeIcon(), {
            defaultProps: { className: iconClasses },
            overrideProps: predefinedProps => this.handleIconOverrides,
          })}
        </ElementType>)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Thanks. Fixed.

Copy link
Contributor

@mnajdova mnajdova left a comment

Choose a reason for hiding this comment

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

I left couple of comments, other than that it looks good to be merged here.

@codepretty
Copy link
Collaborator

If you have time, we should update the doc to just be "an icon" instead of "a search icon" since it really could be anything there.
image

@alinais
Copy link
Contributor Author

alinais commented Aug 7, 2018

@codepretty , thanks. Fixed.

@alinais alinais closed this Aug 7, 2018
@alinais alinais reopened this Aug 7, 2018
@alinais alinais closed this Aug 7, 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.

None yet

3 participants