Skip to content
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

New Component: Card #5322

Closed
11 of 12 tasks
micahgodbolt opened this issue Jun 22, 2018 · 28 comments
Closed
11 of 12 tasks

New Component: Card #5322

micahgodbolt opened this issue Jun 22, 2018 · 28 comments
Assignees
Labels
Component: Card Resolution: Soft Close Soft closing inactive issues over a certain period

Comments

@micahgodbolt
Copy link
Member

micahgodbolt commented Jun 22, 2018

Component Details

A Card is a surface to display content and actions about a single topic. It acts as a container for actionable information like text, images and icons.

A Card should abstract styling properties and utilize them in tandem with theme variables. Some of the properties to abstract are:

  • Paddings
  • Widths
  • Heights
  • Shadowing
  • Borders
  • Colors

Considerations and Design Decisions

There are a couple of things to consider and discuss regarding the implementation of a Card component. Some of these considerations are outlined below:

  • The introduction of a compact Card, which places the items in a row to use less screen space.
  • A Card is responsive to screen size changes, but only within a limited range. A default minimum and maximum width are provided, with the ability to override this for custom scenarios.
  • Fixed height in individual scenarios vs stretching height in multiple card scenarios.
  • The default behavior is defined for margins and padding, and the component provides an easy way to opt out of this default behavior.
  • Hovering styling indicates a Card is clickable.

Component Documentation

Imports

The Stack component is used to generate the Card container.

Exports/ Component Breakdown

Both the Card and CardItem components are exported, as well as the Card and CardItem properties defined in Card.types and CardItem.types respectively.

Intended Package

The component lives in a newly created react-cards package.

Code mockup/example

Regular Card Example

const styles = mergeStyleSets({
   siteText: {
      color: '#025F52',
      fontSize: 12,
      fontWeight: FontWeights.semibold
   },
   descriptionText: {
      color: '#333333',
      fontSize: 14,
      fontWeight: FontWeights.regular
   },
   helpfulText: {
      color: '#333333',
      fontSize: 12,
      fontWeight: FontWeights.regular
   },
   icon: {
      color: '#0078D4',
      fontSize: 16,
      fontWeight: FontWeights.regular
   }
});

const tokens = {
   sectionStack: {
      childrenGap: 30
   },
   cardFooterStack: {
      childrenGap: 16
   }
};

<Card onClick={alertClicked}>
   <Persona text="Kevin Jameson" secondaryText="Feb 2, 2019" />
   <Card.Item tokens={{ margin: '0 -13px' }}>
      <Image src="https://placehold.it/286x144" width="100%" />
   </Card.Item>
   <Text className={styles.siteText}>Contoso</Text>
   <Text className={styles.descriptionText}>Contoso Denver expansion design marketing hero guidelines</Text>
   <Text className={styles.helpfulText}>Is this recommendation helpful?</Text>
   <Card.Item>
      <Stack horizontal tokens={tokens.cardFooterStack} padding="12px 0 0" styles={{ root: { borderTop: '1px solid #F3F2F1' } }}>
         <Icon iconName="RedEye" className={styles.icon} />
         <Icon iconName="SingleBookmark" className={styles.icon} />
         <Stack.Item grow={1}>
            <span />
         </Stack.Item>
         <Icon iconName="MoreVertical" className={styles.icon} />
      </Stack>
   </Card.Item>
</Card>

Compact Card Example

const styles = mergeStyleSets({
   siteText: {
      color: '#025F52',
      fontSize: 12,
      fontWeight: FontWeights.semibold
   },
   descriptionText: {
      color: '#333333',
      fontSize: 14,
      fontWeight: FontWeights.regular
   },
   helpfulText: {
      color: '#333333',
      fontSize: 12,
      fontWeight: FontWeights.regular
   },
   icon: {
      color: '#0078D4',
      fontSize: 16,
      fontWeight: FontWeights.regular
   }
});

<Card compact={true} onClick={alertClicked}>
   <Card.Item tokens={{ margin: '-12px 0 -12px -12px' }}>
      <Image src="https://placehold.it/180x135" />
   </Card.Item>
   <Stack gap={12}>
      <Text className={styles.siteText}>Contoso</Text>
      <Text className={styles.descriptionText}>Contoso Denver expansion design marketing hero guidelines</Text>
      <Text className={styles.helpfulText}>Is this recommendation helpful?</Text>
   </Stack>
   <Stack gap={16} padding="0 0 0 12px" styles={{ root: { borderLeft: '1px solid #F3F2F1' } }}>
      <Icon iconName="RedEye" className={styles.icon} />
      <Icon iconName="SingleBookmark" className={styles.icon} />
      <Stack.Item grow={1}>
         <span />
      </Stack.Item>
      <Icon iconName="MoreVertical" className={styles.icon} />
   </Stack>
</Card>

Card Types

ICardSlots

Name Type Description
root IStackSlot Defines root slot of the component for managing the layout of the Card.

ICardProps

Name Type DefaultValue Description
compact boolean false Defines whether to render a regular or a compact Card.
onClick (ev: React.MouseEvent<HTMLElement>) => void Defines a callback that is called when the Card is clicked.

ICardTokens

Name Type
boxShadow string
boxShadowHovered string
childrenGap number | string
height number | string
maxWidth number | string
minHeight number | string
minWidth number | string
padding number | string
width number | string

Component Ownership

@khmakoto who will be creating the Card component.

Deadlines

The initial basic Card container is expected to be finalized by April 2019, with further variants that may come in a foreseeable future.

Related PRs

Steps

@dzearing
Copy link
Member

This isn't a P1. But it's a feature we need. Let's prioritize

@micahgodbolt
Copy link
Member Author

Should Priority tags only be used for bugs?

@kheide
Copy link

kheide commented Jul 1, 2018

Do you have an ETA for this (and the Tile component) or should we find replacements in the interim?

@micahgodbolt
Copy link
Member Author

@kheide This hasn't been started yet, just a known gap in our component coverage. We're hoping to work on it in the coming month or so.

@kheide
Copy link

kheide commented Jul 6, 2018

Fantastic. Thanks!

Also I just discovered the Chiclet component which sort of also helps.

@micahgodbolt
Copy link
Member Author

@mikewheaton making sure you're aware of this issue for tracking work on card.

@mikewheaton mikewheaton changed the title Create Box/Card Component Card component Jan 28, 2019
@danielgwilson
Copy link

+1

@khmakoto
Copy link
Member

@tenzin-copart just updated the description to better reflect current deadlines, but the short answer is that yes, there is a basic Card component that we are trying to ship by March 2019.

Work on this should start speeding up beginning next week and all related PRs will be linked to this issue.

@khmakoto khmakoto modified the milestones: March 2019, April 2019 Apr 1, 2019
@tenzin-copart
Copy link

tenzin-copart commented Apr 16, 2019

@khmakoto - Is this component ready now?

@khmakoto
Copy link
Member

Hi @tenzin-copart we have a prototype in its own @uifabric/react-cards package if you want to try out today and it's close to be finished. We hosted an API review last Friday which surface some extra work we need to do but you can play with it for now if you're interested in checking it out.

@khmakoto khmakoto modified the milestones: April 2019, May 2019 May 9, 2019
@Rtoribiog
Copy link

hello @khmakoto any update on this ? Thanks

@khmakoto
Copy link
Member

khmakoto commented Jul 5, 2019

Hi @Rtoribiog, the Card component is in a state where we deem it ready to be promoted to our official package, but we've been having some difficulties doing that because of the work we're doing in #9645. In the meantime, if you want to try the production-ready component, you can import it from the @uifabric/react-cards package.

@micahgodbolt micahgodbolt removed this from the May 2019 milestone Aug 19, 2019
@Sentri
Copy link

Sentri commented Nov 25, 2019

Since #9645 is on hold, are there any new plans now to introduce this into the main package?

@khmakoto
Copy link
Member

Hi @Sentri, I don't think there's any effort to bring it into the main package right now since #9645 is on hold but you can use the @uifabric/react-cards package. The API is basically finished at this point so if we ever decide to move it to the main package it shouldn't break your project.

@vitaliyKorzhenko
Copy link

vitaliyKorzhenko commented Apr 3, 2020

@Sentri How I can change styles if I clicked on card? I need use selector?

@khmakoto
Copy link
Member

khmakoto commented Apr 6, 2020

@vitaliyKorzhenko yes, you do need to use a selector in that case.

@beeisabelm
Copy link

@khmakoto the compliance issue blocks us from using experimental API. What is the blocker or constraint that needs to be done in order to ship it? Thanks.

@jeffersoneagley
Copy link

jeffersoneagley commented Jul 20, 2020

Does Card respond to a Customizer yet? I tried setting some styles, and it didn't seem to change anything. I could be doing it wrong 🤷‍♂️

export const makeScopedSettings = theme => ({
// ...
  Card: {
    styles: cardStyles(theme),
  },
  CardItem: {
    styles: cardStyles(theme),
  },
//.......... etc

For now, I'm overriding the .ms-Card class as a workaround.

@jeffersoneagley
Copy link

Any updates on the cards getting merged in?

@khmakoto
Copy link
Member

@beeisabelm @jeffersoneagley we're currently in the process of revamping our components from many angles: bundle size, styling, API interface, etc. Card will be part of these components and that will hopefully remove any barriers for merging. We'll keep you updated on the process.

@jeffersoneagley
Copy link

I noticed they were just marked as deprecated. Should we be moving to a Card from elsewhere in the library then? I've got people asking now that they're seeing a strikethrough in their VSCode.

@khmakoto
Copy link
Member

@jeffersoneagley like I mentioned in my comment above, we're currently in the process of revamping our components from many angles. I don't have an ETA yet for when Card will be moved to this new model but we'll keep you updated.

@jeffersoneagley
Copy link

Right, but it was just recently marked deprecated, and that's causing compliance issues for some people now. I don't want to go reinvent the wheel on it, but deprecated kind of implies there's something else I should be using.

@Pixelatex
Copy link

So I was very confused why Card is not available yet in fluentui... many of your components seem to use some form of a card like the DetailsList. Please can we get a basic Card version merged?

@msft-fluent-ui-bot
Copy link
Collaborator

Because this issue has not had activity for over 150 days, we're automatically closing it for house-keeping purposes.

Still require assistance? Please, create a new issue with up-to date details.

@msft-fluent-ui-bot msft-fluent-ui-bot added the Resolution: Soft Close Soft closing inactive issues over a certain period label Apr 7, 2022
@jeffersoneagley
Copy link

No bot, this is still an open question.

@khmakoto
Copy link
Member

We're working on a new version of the Card component, please look at #19336 for an epic tracking this work.

@microsoft microsoft locked as resolved and limited conversation to collaborators May 28, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Component: Card Resolution: Soft Close Soft closing inactive issues over a certain period
Projects
None yet
Development

No branches or pull requests