-
Notifications
You must be signed in to change notification settings - Fork 2.8k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Card: Initial implementation (#14206)
#### Pull request checklist - [ ] Addresses an existing issue: Fixes #0000 - [ ] Include a change request file using `$ yarn change` #### Description of changes This PR contains the first implementation of a `Card` component using our latest stack of technologies. ![image](https://user-images.githubusercontent.com/7798177/88445656-d77aca00-cdd8-11ea-8a50-f0d486a6998e.png) #### Notes - It's using `office-ui-fabric-react` components for the examples. - There are a couple of TODOs regarding some props that I still need to address.
- Loading branch information
Showing
50 changed files
with
2,026 additions
and
9 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
{ | ||
"type": "minor", | ||
"comment": "Moving SizeValue const from react-button to theme package.", | ||
"packageName": "@fluentui/react-button", | ||
"email": "[email protected]", | ||
"dependentChangeType": "patch", | ||
"date": "2020-07-25T01:11:26.080Z" | ||
} |
8 changes: 8 additions & 0 deletions
8
change/@fluentui-react-theme-provider-2020-07-24-18-12-08-card.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
{ | ||
"type": "minor", | ||
"comment": "Adding Card tokens to theme.", | ||
"packageName": "@fluentui/react-theme-provider", | ||
"email": "[email protected]", | ||
"dependentChangeType": "patch", | ||
"date": "2020-07-25T01:12:07.950Z" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
{ | ||
"type": "minor", | ||
"comment": "Moving SizeValue const from react-button to theme package.", | ||
"packageName": "@fluentui/theme", | ||
"email": "[email protected]", | ||
"dependentChangeType": "patch", | ||
"date": "2020-09-14T01:11:58.698Z" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
{ | ||
"type": "minor", | ||
"comment": "Card: Adding initial implementation based on latest technology stack - compose, scss, tokens.", | ||
"packageName": "@uifabric/react-cards", | ||
"email": "[email protected]", | ||
"dependentChangeType": "patch", | ||
"date": "2020-07-25T01:11:58.698Z" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
export * from './withThemeProvider'; |
9 changes: 9 additions & 0 deletions
9
packages/react-cards/.storybook/decorators/withThemeProvider.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
import React from 'react'; | ||
import { ThemeProvider } from '@fluentui/react-theme-provider'; | ||
import { useTheme } from '../knobs/theme'; | ||
|
||
export const withThemeProvider = storyFn => { | ||
const { theme } = useTheme(); | ||
|
||
return <ThemeProvider theme={theme}>{storyFn()}</ThemeProvider>; | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
import { select } from '@storybook/addon-knobs'; | ||
|
||
const themeSelectorLabel = 'Theme'; | ||
|
||
const TeamsTheme = { | ||
tokens: { | ||
body: { | ||
background: 'white', | ||
contentColor: 'black', | ||
}, | ||
|
||
card: { | ||
size: { | ||
small: { | ||
height: '100%', | ||
width: '200px', | ||
}, | ||
smaller: { | ||
height: '100%', | ||
width: '200px', | ||
}, | ||
smallest: { | ||
height: '100%', | ||
width: '200px', | ||
}, | ||
medium: { | ||
height: '100%', | ||
width: '300px', | ||
}, | ||
large: { | ||
height: '100%', | ||
width: '500px', | ||
}, | ||
larger: { | ||
height: '100%', | ||
width: '500px', | ||
}, | ||
largest: { | ||
height: '100%', | ||
width: '500px', | ||
}, | ||
}, | ||
}, | ||
}, | ||
stylesheets: [], | ||
}; | ||
|
||
const themeOptions = [{ label: 'Teams', theme: TeamsTheme }]; | ||
const defaultThemeOption = themeOptions[0]; | ||
|
||
export const useTheme = () => select(themeSelectorLabel, themeOptions, defaultThemeOption); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
export * from './next/index'; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,79 @@ | ||
import * as React from 'react'; | ||
import { TestImages } from '@uifabric/example-data'; | ||
import { | ||
DefaultButton, | ||
IconButton, | ||
Image, | ||
ImageFit, | ||
Persona, | ||
PersonaPresence, | ||
Stack, | ||
Text, | ||
} from 'office-ui-fabric-react'; | ||
import { Card, CardBody, CardFooter, CardHeader } from '@uifabric/react-cards/lib/next'; | ||
|
||
function onClick() { | ||
// eslint-disable-next-line no-alert | ||
alert('Card was clicked'); | ||
} | ||
|
||
export const TeamsCards = () => ( | ||
<Stack gap={40}> | ||
<div> | ||
<Text variant="xLarge">Basic Card</Text> | ||
<Card onClick={onClick}> | ||
<CardHeader> | ||
<Persona | ||
imageUrl={TestImages.personaMale} | ||
text="Carmen Gaylord" | ||
secondaryText="Direct Communications Agent" | ||
presence={PersonaPresence.offline} | ||
/> | ||
</CardHeader> | ||
<CardBody> | ||
Voluptatibus commodi ut. Neque eum odit eius repellat molestiae illo aut ut illum. Nulla vel et odit | ||
consequatur dolorem molestias. Rem rerum animi consequatur. | ||
</CardBody> | ||
</Card> | ||
</div> | ||
<div> | ||
<Text variant="xLarge">Only header</Text> | ||
<Card onClick={onClick}> | ||
<CardHeader fitted> | ||
<Persona | ||
imageUrl={TestImages.personaMale} | ||
text="Carmen Gaylord" | ||
secondaryText="Direct Communications Agent" | ||
presence={PersonaPresence.offline} | ||
/> | ||
</CardHeader> | ||
</Card> | ||
</div> | ||
<div> | ||
<Text variant="xLarge">Only body</Text> | ||
<Card onClick={onClick}> | ||
<CardBody fitted> | ||
<Stack gap={10}> | ||
<Image src="http://placehold.it/500x500" imageFit={ImageFit.cover} height={300} maximizeFrame /> | ||
<Text>Citizens of distant epochs muse about at theedge of forever hearts of the...</Text> | ||
</Stack> | ||
</CardBody> | ||
</Card> | ||
</div> | ||
<div> | ||
<Text variant="xLarge">Only footer</Text> | ||
<Card onClick={onClick}> | ||
<CardFooter fitted> | ||
<Stack horizontal horizontalAlign="space-between"> | ||
<DefaultButton text="Action" /> | ||
<Stack horizontal> | ||
<IconButton iconProps={{ iconName: 'FavoriteStar' }} /> | ||
<IconButton iconProps={{ iconName: 'Download' }} /> | ||
<IconButton iconProps={{ iconName: 'More' }} /> | ||
</Stack> | ||
</Stack> | ||
</CardFooter> | ||
</Card> | ||
</div> | ||
</Stack> | ||
); |
Oops, something went wrong.