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

fix(Avatar): Adding dark and contrast theme files for Avatar and Status Indicator. #373

Merged
merged 14 commits into from
Oct 31, 2018

Conversation

bcalvery
Copy link
Contributor

@bcalvery bcalvery commented Oct 18, 2018

Modified Avatar to support Dark and Contrast themes

Before:
image
image

After:
image
image

image

@codecov
Copy link

codecov bot commented Oct 18, 2018

Codecov Report

Merging #373 into master will decrease coverage by 0.12%.
The diff coverage is 100%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master     #373      +/-   ##
==========================================
- Coverage   91.77%   91.64%   -0.13%     
==========================================
  Files          41       41              
  Lines        1325     1341      +16     
  Branches      194      197       +3     
==========================================
+ Hits         1216     1229      +13     
- Misses        105      108       +3     
  Partials        4        4
Impacted Files Coverage Δ
src/components/Status/Status.tsx 100% <100%> (ø) ⬆️
src/components/List/ListItem.tsx 93.61% <0%> (-6.39%) ⬇️

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 3499658...0a813d5. Read the comment docs.

@alinais alinais added the redlines Update of the redlines for the mentioned component label Oct 22, 2018
variables: { color: 'white' }, // This is temporary. There is a ToDo to use icon's text/fill color for box-shadow, currently it uses color
styles: styles.icon,
variables: variables.icon,
className: classes.icon,
Copy link
Contributor

@kuzhelov kuzhelov Oct 30, 2018

Choose a reason for hiding this comment

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

these classes.icon shouldn't be passed, as classes.icon contain already processed styles that are transformed to classes (styles.icon -> classes.icon). We should just pass original styles.icon and let Icon component process them by itself. This is critical to ensure that these styles.icon will be correctly merged with those that could be provided to icon shorthand in a following way:

<Status icon={{ styles: ... }} />


const status = { color: 'green', icon: 'check', title: 'Available' }

const AvatarUsageExampleShorthand = () => (
Copy link
Contributor

Choose a reason for hiding this comment

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

just a note for future: for all the components we have this section where examples that are rather theme-specific are provided. It is a clear indicator that we should think about mechanisms for theme developers to define custom docs section where theme-specific examples will be provided.

@@ -0,0 +1,40 @@
import { pxToRem } from '../../../../lib'
Copy link
Contributor

@kuzhelov kuzhelov Oct 30, 2018

Choose a reason for hiding this comment

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

note that these styles are one-to-one the styles that are used for the default theme. To eliminate code repetition we could just reuse the ones that are used for default theme.

const darkThemeOverrides = {
  componentVariables: {
    ...
    Avatar: { /* .. overriden variables for Avatar component .. */ }
  }
}
..

const darkTheme = mergeThemes(defaultTheme, darkThemeOverrides)

@@ -0,0 +1,9 @@
export interface IAvatarVariables {
Copy link
Contributor

Choose a reason for hiding this comment

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

the type declared for default theme should be reused - this would guarantee consistency of variables across different theme variants

@@ -0,0 +1,63 @@
import { pxToRem } from '../../../../lib'
Copy link
Contributor

Choose a reason for hiding this comment

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

same story here - we shouldn't replicate the same styles, but rather introduce overrides that are specific to dark theme

Copy link
Contributor

@kuzhelov kuzhelov left a comment

Choose a reason for hiding this comment

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

there is lots of code duplication at the moment, the ones that are caused by literal copying the styles and variables of default theme into dark and high-contrast one. Lets address that by using the following approach:

const darkThemeOverrides = {
  componentVariables: {
    ...
    Avatar: { /* .. overriden variables for Avatar component .. */ }
  }
}
..

const darkTheme = mergeThemes(defaultTheme, darkThemeOverrides)

@kuzhelov kuzhelov added needs author feedback Author's opinion is asked and removed 🚀 ready for review labels Oct 30, 2018
@kuzhelov kuzhelov removed the needs author feedback Author's opinion is asked label Oct 31, 2018
Copy link
Contributor

@kuzhelov kuzhelov left a comment

Choose a reason for hiding this comment

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

please, just update CHANGELOG before merging 👍

@bcalvery bcalvery merged commit 5bb41a4 into master Oct 31, 2018
@layershifter layershifter deleted the fix/avatar-darktheme branch November 9, 2018 09:23
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
ready for merge redlines Update of the redlines for the mentioned component
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants