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

feat(ItemLayout): added ItemLayout component #60

Merged
merged 15 commits into from
Aug 20, 2018
Merged

Conversation

mnajdova
Copy link
Contributor

@mnajdova mnajdova commented Aug 8, 2018

ItemLayout

The Item layout will be a layout component for aligning content in form of media, header (and headerMedia), content (and contentMedia) and end media. This PR fixes #27 and fixes #71.

With this PR the ListItem is also updated to use the ItemLayout component.

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

API Proposal

content: PropTypes.any

Shorthand for primary content.

contentMedia: PropTypes.any

End media for the content

header: PropTypes.any

Shorthand for the header.

headerMedia: PropTypes.any

End media for the header

media: PropTypes.any

General start media.

endMedia: PropTypes.any

General end media

renderContentArea: PropTypes.any

Custom function for generating the content area.

renderHeaderArea: PropTypes.any

Custom functino for generating the header area.

renderMainArea: PropTypes.any

Custom function for generating the main area.

important: PropTypes.bool

An item can appear more important and draw the user's attention.

truncateContent: PropTypes.bool

Prop for indicating if the content should be truncated.

truncateHeader: PropTypes.bool

Prop for indicating if the header should be truncated.

debug: PropTypes.bool

Toggle debug mod

Usage example

image

Jsx code:

<ItemLayout
      media={<Image src="public/images/avatar/small/nom.jpg" avatar />}
      header="Dante Schneider - Super long title here"
      headerMedia="5:22:40 PM"
      content="The GB pixel is down, navigate the virtual interface!"
      contentMedia="!!"
      truncateHeader={true}
      truncateContent={true}
    />

Result:

<div class="ui-layout d e f ui-itemlayout a b c">
    <div class="ui-layout__start">
      <img role="presentation" src="public/images/avatar/small/nom.jpg" class="ui-image g h i j k" />
    </div>
    <span class="ui-layout__gap"></span>
    <div class="ui-layout__main">
      <div class="ui-item-layout__main" style="grid-template-rows:1fr 1fr">
        <div class="ui-layout l e m ui-item-layout__header">
          <div class="ui-layout__main al am an">Dante Schneider - Super long title here</div>
          <span class="ui-layout__gap"></span>
          <div class="ui-layout__end">
            <span class="ui-item-layout__headerMedia">5:22:40 PM</span>
          </div>
        </div>
        <div class="ui-layout n e m ui-item-layout__content">
          <div class="ui-layout__main al am an">The GB pixel is down, navigate the virtual interface!</div>
          <span class="ui-layout__gap"></span>
          <div class="ui-layout__end">!!</div>
        </div>
      </div>
    </div>
  </div>

@codecov
Copy link

codecov bot commented Aug 8, 2018

Codecov Report

Merging #60 into master will increase coverage by 0.72%.
The diff coverage is 89.74%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master      #60      +/-   ##
==========================================
+ Coverage   86.29%   87.02%   +0.72%     
==========================================
  Files          39       41       +2     
  Lines         664      709      +45     
  Branches       90       94       +4     
==========================================
+ Hits          573      617      +44     
- Misses         88       89       +1     
  Partials        3        3
Impacted Files Coverage Δ
src/index.ts 100% <100%> (ø) ⬆️
src/components/ItemLayout/index.tsx 100% <100%> (ø)
src/components/List/ListItem.tsx 95% <100%> (+12.64%) ⬆️
src/components/ItemLayout/ItemLayout.tsx 85.45% <85.45%> (ø)

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 81d4a46...b5b94a2. Read the comment docs.

@mnajdova mnajdova changed the title -added item layout component identical to the list item implementation feat(ItemLayout): added ItemLayout component Aug 8, 2018
@mnajdova mnajdova changed the title feat(ItemLayout): added ItemLayout component [WIP] feat(ItemLayout): added ItemLayout component Aug 8, 2018
header="Irving Kuhic"
headerMedia="7:26:56 AM"
content="Program the sensor to the SAS alarm through the haptic SQL card!"
debug={knobs.debug}
Copy link
Member

Choose a reason for hiding this comment

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

Since this is the full example with a debug display knob to help the user understand the full layout, let's also include some endMedia here. Perhaps some kind of icon would be great.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I added the end media with ellipses (…) to this examples, as well as the truncate example, as we have there even more knobs.


handleMouseLeave = () => {
this.setState({ isHovering: false })
}
Copy link
Member

Choose a reason for hiding this comment

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

The ItemLayout should not have any listeners or state. Let's strip this.

A layout component should only handle the CSS layout itself. The rest of the logic is left to the component implementing the layout.

@levithomason
Copy link
Member

Please add Fixes #27 to this PR description. It will link the issues and auto close the issue when this is merged.

https://help.github.com/articles/closing-issues-using-keywords/

manajdov added 5 commits August 9, 2018 10:47
-updated ListItem component to work with the ItemLayout
# Conflicts:
#	CHANGELOG.md
#	src/components/ItemLayout/itemLayoutVariables.ts
#	src/components/List/List.tsx
#	src/components/List/ListItem.tsx
#	src/themes/teams/components/List/listItemStyles.ts
@mnajdova mnajdova changed the title [WIP] feat(ItemLayout): added ItemLayout component feat(ItemLayout): added ItemLayout component Aug 9, 2018

// Item
vars.itemPaddingLeft = pxToRem(20)
vars.itemPaddingRight = pxToRem(18)
Copy link
Member

Choose a reason for hiding this comment

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

This looks like a regression. The listVariables.ts was moved to listItemVariables.ts and the variable names were updated to remove the list* portion.

See master:
https://github.com/stardust-ui/react/blob/master/src/themes/teams/components/List/listItemVariables.ts

color: '#fff',
cursor: 'pointer',
},
}),
Copy link
Member

Choose a reason for hiding this comment

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

We should move the non-position related styles back to the ListItem from the Layout. The layout should not define colors, fonts, etc but only layout styling.

},

media: ({ props }) => {
const { important } = props
Copy link
Member

Choose a reason for hiding this comment

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

Since important will likely vary depending on the parent component implementing the items, let's move this prop and style also back to the ListItem side. Keeping just position and DOM structure in the layouts.

lineHeight: variables.contentLineHeight,
}),
contentMedia: () => ({}),
endMedia: () => ({}),
Copy link
Member

Choose a reason for hiding this comment

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

No need for empty styles

Copy link
Member

@levithomason levithomason left a comment

Choose a reason for hiding this comment

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

See comments for changes. Probably good to merge once those are addressed. We can iterate on the rest afterward in other PRs.

manajdov added 6 commits August 13, 2018 13:02
# Conflicts:
#	src/components/List/ListItem.tsx
@levithomason levithomason merged commit bf5313b into master Aug 20, 2018
@levithomason levithomason deleted the feat/item-layout branch August 20, 2018 22:38
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.

List item header does not have rem size feat: Extract the Item Layout from the List.Item
2 participants