forked from microsoft/fluentui
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Staging the react-avatar package; (microsoft#14518)
* Adding react-avatar. * Adding Avatar. * Updating Avatar to use raw sass. * blah. * more updates. * Changes. * Shorthand props now work * more updates. * Adding PersonaCoin example. * Cleanup. * Updating url. * changes * more changes. * Adding button. Renaming handledProp to mappedProp. * Addressing missing font definitions. Adding stylesheet support to themeprovider. * Addressing review feedback. * Merge branch 'master' of https://github.com/microsoft/fluentui into feat/avatar # Conflicts: # apps/test-bundles/package.json # packages/fluentui/react-northstar/src/components/Provider/Provider.tsx # yarn.lock * Undoing changes. * undoing a few more changes. * Updating react-compose dependency * Fixing broken things. * wip * Update packages/react-compose/src/utils.ts * converted all components to use react-compose * wip * Integrating useStylesheet. * Removing dupe stylesheets provider. * Merge branch 'master' of https://github.com/microsoft/fluentui into feat/avatar # Conflicts: # .vscode/settings.json # packages/fluentui/react-northstar/src/utils/felaStylisEnhancer.ts # packages/react-compose/etc/react-compose.api.md # packages/react-compose/package.json # packages/react-compose/src/compose.ts # packages/react-compose/src/types.ts # packages/react-compose/src/utils.ts # scripts/package.json # yarn.lock * updated readme * Change files * removing private * Change files * fixing lint. * Ensuring tests work. * Awesome. * updates. * yarn updates. Co-authored-by: Marija Najdova <[email protected]>
- Loading branch information
1 parent
8f78cf1
commit 8e55131
Showing
45 changed files
with
882 additions
and
2 deletions.
There are no files selected for viewing
8 changes: 8 additions & 0 deletions
8
change/@fluentui-react-avatar-2020-08-13-18-36-08-feat-avatar.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": "patch", | ||
"comment": "Seeding initial package.", | ||
"packageName": "@fluentui/react-avatar", | ||
"email": "[email protected]", | ||
"dependentChangeType": "patch", | ||
"date": "2020-08-14T01:36:08.465Z" | ||
} |
8 changes: 8 additions & 0 deletions
8
change/@fluentui-react-compose-2020-08-13-18-32-24-feat-avatar.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": "Updating readme.", | ||
"packageName": "@fluentui/react-compose", | ||
"email": "[email protected]", | ||
"dependentChangeType": "patch", | ||
"date": "2020-08-14T01:32:24.265Z" | ||
} |
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,32 @@ | ||
*.api.json | ||
*.config.js | ||
*.log | ||
*.nuspec | ||
*.test.* | ||
*.yml | ||
.editorconfig | ||
.gitattributes | ||
.gitignore | ||
.vscode | ||
coverage | ||
dist-storybook | ||
dist/*.stats.html | ||
dist/*.stats.json | ||
dist/demo*.* | ||
fabric-test* | ||
gulpfile.js | ||
images | ||
index.html | ||
jsconfig.json | ||
node_modules | ||
results | ||
src/**/* | ||
!src/**/examples/*.tsx | ||
!src/**/docs/**/*.md | ||
!src/**/*.types.ts | ||
temp | ||
tsconfig.json | ||
tsd.json | ||
tslint.json | ||
typings | ||
visualtests |
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,2 @@ | ||
registry=https://registry.npmjs.org/ | ||
|
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 @@ | ||
const custom = require('@uifabric/build/storybook/webpack.config'); | ||
|
||
module.exports = { | ||
webpackFinal: config => { | ||
return custom({ config }); | ||
}, | ||
addons: ['@storybook/addon-a11y/register', 'storybook-addon-performance/register'], | ||
}; |
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,6 @@ | ||
import { addons } from '@storybook/addons'; | ||
|
||
addons.setConfig({ | ||
showPanel: true, | ||
panelPosition: 'bottom', | ||
}); |
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,32 @@ | ||
import { initializeIcons } from '@uifabric/icons'; | ||
import generateStoriesFromExamples from '@uifabric/build/storybook/generateStoriesFromExamples'; | ||
import { configure, addParameters, addDecorator } from '@storybook/react'; | ||
import { withInfo } from '@storybook/addon-info'; | ||
import { withA11y } from '@storybook/addon-a11y'; | ||
import { withPerformance } from 'storybook-addon-performance'; | ||
|
||
addDecorator(withPerformance); | ||
addDecorator(withInfo()); | ||
addDecorator(withA11y()); | ||
addParameters({ | ||
a11y: { | ||
manual: true, | ||
}, | ||
}); | ||
|
||
initializeIcons(); | ||
|
||
const req = require.context('../src', true, /\.stories\.tsx$/); | ||
|
||
function loadStories() { | ||
const stories = new Map(); | ||
|
||
req.keys().forEach(key => { | ||
generateStoriesFromExamples({ key, req, stories }); | ||
}); | ||
|
||
// convert stories Set to array | ||
return [...stories.values()]; | ||
} | ||
|
||
configure(loadStories, module); |
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,4 @@ | ||
{ | ||
"name": "@fluentui/react-avatar", | ||
"entries": [] | ||
} |
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,3 @@ | ||
# Change Log - @fluentui/react-avatar | ||
|
||
This log was last generated on Mon, 23 Mar 2020 18:44:38 GMT and should not be manually modified. |
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,15 @@ | ||
@uifabric/react-avatar | ||
|
||
Copyright (c) Microsoft Corporation | ||
|
||
All rights reserved. | ||
|
||
MIT License | ||
|
||
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the ""Software""), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: | ||
|
||
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. | ||
|
||
THE SOFTWARE IS PROVIDED *AS IS*, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. | ||
|
||
Note: Usage of the fonts and icons referenced in Office UI Fabric is subject to the terms listed at https://aka.ms/fabric-assets-license |
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,17 @@ | ||
# @fluentui/react-avatar | ||
|
||
**React Avatar components for [Fluent UI](https://dev.microsoft.com/fluentui)** | ||
|
||
These are not production-ready components and **should never be used in product**. This space is useful for testing new components whose APIs might change before final release. | ||
|
||
To import ReactAvatar components: | ||
|
||
```js | ||
import { ComponentName } from '@fluentui/react-avatar'; | ||
``` | ||
|
||
Once the Avatar component graduates to a production release, the component will be available at: | ||
|
||
```js | ||
import { ComponentName } from '@fluentui/react'; | ||
``` |
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,5 @@ | ||
{ | ||
"copyTo": { | ||
"dist": [] | ||
} | ||
} |
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,12 @@ | ||
/** Jest test setup file. */ | ||
|
||
const { configure } = require('enzyme'); | ||
const Adapter = require('enzyme-adapter-react-16'); | ||
|
||
// Mock requestAnimationFrame for React 16+. | ||
global.requestAnimationFrame = callback => { | ||
setTimeout(callback, 0); | ||
}; | ||
|
||
// Configure enzyme. | ||
configure({ adapter: new Adapter() }); |
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 @@ | ||
const { createConfig } = require('@uifabric/build/jest/jest-resources'); | ||
const path = require('path'); | ||
|
||
const config = createConfig({ | ||
setupFiles: [path.resolve(path.join(__dirname, 'config', 'tests.js'))], | ||
}); | ||
|
||
module.exports = config; |
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,3 @@ | ||
const { preset } = require('@uifabric/build'); | ||
|
||
preset(); |
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,64 @@ | ||
{ | ||
"name": "@fluentui/react-avatar", | ||
"version": "0.1.0", | ||
"description": "React components for building Microsoft web experiences.", | ||
"main": "lib-commonjs/index.js", | ||
"module": "lib/index.js", | ||
"typings": "lib/index.d.ts", | ||
"sideEffects": [ | ||
"lib/version.js" | ||
], | ||
"repository": { | ||
"type": "git", | ||
"url": "https://github.com/microsoft/fluentui" | ||
}, | ||
"license": "MIT", | ||
"scripts": { | ||
"build": "just-scripts build", | ||
"bundle": "just-scripts bundle", | ||
"clean": "just-scripts clean", | ||
"code-style": "just-scripts code-style", | ||
"just": "just-scripts", | ||
"lint": "just-scripts lint", | ||
"start": "just-scripts dev:storybook", | ||
"start-test": "just-scripts jest-watch", | ||
"test": "just-scripts test", | ||
"update-api": "just-scripts update-api", | ||
"update-snapshots": "just-scripts jest -u" | ||
}, | ||
"devDependencies": { | ||
"@fluentui/react-conformance": "^0.1.0", | ||
"@types/enzyme": "3.10.3", | ||
"@types/enzyme-adapter-react-16": "1.0.3", | ||
"@types/jest": "~24.9.0", | ||
"@types/react": "16.8.25", | ||
"@types/react-dom": "16.8.4", | ||
"@types/react-test-renderer": "^16.0.0", | ||
"@types/webpack-env": "1.15.1", | ||
"@uifabric/build": "^7.0.0", | ||
"@uifabric/jest-serializer-merge-styles": "^7.0.33", | ||
"enzyme": "~3.10.0", | ||
"enzyme-adapter-react-16": "^1.15.0", | ||
"es6-weak-map": "^2.0.2", | ||
"react": "16.8.6", | ||
"react-app-polyfill": "~1.0.1", | ||
"react-dom": "16.8.6", | ||
"react-test-renderer": "^16.3.0" | ||
}, | ||
"dependencies": { | ||
"@fluentui/react-compose": "^0.14.4", | ||
"@fluentui/accessibility": "^0.51.0", | ||
"@fluentui/react-theme-provider": "^0.7.1", | ||
"@fluentui/react-stylesheets": "^0.1.16", | ||
"@uifabric/set-version": "^7.0.19", | ||
"@uifabric/react-hooks": "^7.8.1", | ||
"@uifabric/utilities": "^7.27.1", | ||
"tslib": "^1.10.0" | ||
}, | ||
"peerDependencies": { | ||
"@types/react": ">=16.8.0 <17.0.0", | ||
"@types/react-dom": ">=16.8.0 <17.0.0", | ||
"react": ">=16.8.0 <17.0.0", | ||
"react-dom": ">=16.8.0 <17.0.0" | ||
} | ||
} |
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 './components/Avatar/index'; |
109 changes: 109 additions & 0 deletions
109
packages/react-avatar/src/components/Avatar/Avatar.scss
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,109 @@ | ||
// Define default variable values | ||
:root { | ||
--avatarSizeSmallest: 20px; | ||
--avatarSizeSmaller: 24px; | ||
--avatarSizeSmall: 28px; | ||
--avatarSizeMedium: 32px; | ||
--avatarSizeLarge: 44px; | ||
--avatarSizeLarger: 64px; | ||
--avatarSizeLargest: 96px; | ||
--avatarBorderColor: transparent; | ||
--avatarBorderWidth: 0; | ||
--avatarBorderRadius: 9999px; | ||
|
||
--squareAvatarBorderRadius: 3px; | ||
--statusBorderColor: transparent; | ||
--statusBorderWidth: 2px; | ||
--avatarFill: rgb(232, 232, 232); | ||
} | ||
|
||
// Root slot | ||
.root { | ||
position: relative; | ||
background-color: inherit; | ||
display: inline-block; | ||
vertical-align: middle; | ||
flex-shrink: 0; | ||
width: var(--avatarSize, var(--avatarSizeMedium)); | ||
height: var(--avatarSize, var(--avatarSizeMedium)); | ||
} | ||
|
||
// Image slot | ||
.image { | ||
position: absolute; | ||
border-radius: var(--avatarBorderRadius); | ||
top: 0; | ||
left: 0; | ||
width: var(--avatarSize, var(--avatarSizeMedium)); | ||
height: var(--avatarSize, var(--avatarSizeMedium)); | ||
height: 100%; | ||
object-fit: cover; | ||
vertical-align: top; | ||
} | ||
|
||
// Label slot | ||
.label { | ||
display: flex; | ||
align-items: center; | ||
justify-content: center; | ||
background-color: var(--avatarFill); | ||
|
||
font-size: calc(var(--avatarSize) / 2.333); | ||
width: var(--avatarSize, var(--avatarSizeMedium)); | ||
height: var(--avatarSize, var(--avatarSizeMedium)); | ||
|
||
vertical-align: top; | ||
text-align: center; | ||
padding: 0px; | ||
border-radius: 99999px; | ||
} | ||
|
||
// Status slot | ||
.status { | ||
position: absolute; | ||
bottom: 0; | ||
right: 0; | ||
box-shadow: 0 0 0 var(--statusBorderWidth) var(--statusBorderColor); | ||
} | ||
|
||
// Root modifier when props.size_ smallest | ||
._size_smallest { | ||
--avatarSize: var(--avatarSizeSmallest); | ||
} | ||
|
||
// Root modifier when props.size_ smaller | ||
._size_smaller { | ||
--avatarSize: var(--avatarSizeSmaller); | ||
} | ||
|
||
// Root modifier when props.size_ small | ||
._size_small { | ||
--avatarSize: var(--avatarSizeSmall); | ||
} | ||
|
||
// Root modifier when props.size_ large | ||
._size_large { | ||
--avatarSize: var(--avatarSizeLarge); | ||
} | ||
|
||
// Root modifier when props.size_ larger | ||
// larger-abc123 | ||
._size_larger { | ||
--avatarSize: var(--avatarSizeLarger); | ||
} | ||
|
||
// Root modifier when props.size_ largest | ||
._size_largest { | ||
--avatarSize: var(--avatarSizeLargest); | ||
} | ||
|
||
// Modifiers | ||
._square { | ||
.image { | ||
border-radius: var(--squareAvatarBorderRadius); | ||
} | ||
|
||
.label { | ||
border-radius: var(--squareAvatarBorderRadius); | ||
} | ||
} |
39 changes: 39 additions & 0 deletions
39
packages/react-avatar/src/components/Avatar/Avatar.stories.tsx
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,39 @@ | ||
import * as React from 'react'; | ||
import { Avatar } from './Avatar'; | ||
import { StoryExample } from '../utils/StoryExample'; | ||
|
||
const imageUrl = 'http://www.fillmurray.com/192/192'; | ||
|
||
export const AvatarCss = () => ( | ||
<StoryExample title="Avatar (css)"> | ||
<Avatar size="smallest" name="John Doe" status="success" /> | ||
<Avatar size="smaller" name="John Doe" status="success" /> | ||
<Avatar size="small" name="John Doe" status="success" /> | ||
<Avatar name="John Doe" status="success" /> | ||
<Avatar size="large" name="Jane Doe" status="error" /> | ||
<Avatar size="larger" name="Lorem Ipsum" status="warning" /> | ||
<Avatar size="largest" name="Lorem Ipsum" status="warning" /> | ||
<Avatar square size="smallest" name="John Doe" status="success" /> | ||
<Avatar square size="smaller" name="John Doe" status="success" /> | ||
<Avatar square size="small" name="John Doe" status="success" /> | ||
<Avatar square name="John Doe" status="success" /> | ||
<Avatar square size="large" name="Jane Doe" status="error" /> | ||
<Avatar square size="larger" name="Lorem Ipsum" status="warning" /> | ||
<Avatar square size="largest" name="Lorem Ipsum" status="warning" /> | ||
|
||
<Avatar size="smallest" name="John Doe" status="success" image={imageUrl} /> | ||
<Avatar size="smaller" name="John Doe" status="success" image={imageUrl} /> | ||
<Avatar size="small" name="John Doe" status="success" image={imageUrl} /> | ||
<Avatar name="John Doe" status="success" image={imageUrl} /> | ||
<Avatar size="large" name="Jane Doe" status="error" image={imageUrl} /> | ||
<Avatar size="larger" name="Lorem Ipsum" status="warning" image={imageUrl} /> | ||
<Avatar size="largest" name="Lorem Ipsum" status="warning" image={imageUrl} /> | ||
<Avatar square size="smallest" name="John Doe" status="success" image={imageUrl} /> | ||
<Avatar square size="smaller" name="John Doe" status="success" image={imageUrl} /> | ||
<Avatar square size="small" name="John Doe" status="success" image={imageUrl} /> | ||
<Avatar square name="John Doe" status="success" image={imageUrl} /> | ||
<Avatar square size="large" name="Jane Doe" status="error" image={imageUrl} /> | ||
<Avatar square size="larger" name="Lorem Ipsum" status="warning" image={imageUrl} /> | ||
<Avatar square size="largest" name="Lorem Ipsum" status="warning" image={imageUrl} /> | ||
</StoryExample> | ||
); |
Oops, something went wrong.