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
feat(icons): add @fluentui/react-icons package #12608
Changes from 12 commits
5c75f0f
4bb74f8
c1ead16
00d92e6
9067043
9d7caee
c755849
5ad91c5
33ef673
9b54c23
ac4d37f
4f29fa9
4c1a26e
b00e1bb
c53857c
c7ad0cf
cd4cd22
8a82319
bb34b65
f90fd23
d02ae3f
8379702
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
import * as React from 'react'; | ||
import { OneDriveIcon, YammerIcon, BorderBlindsIcon } from '@fluentui/react-icons'; | ||
import { mergeStyles } from 'office-ui-fabric-react/lib/Styling'; | ||
|
||
const rootClass = mergeStyles({ | ||
display: 'flex', | ||
selectors: { | ||
'> *': { | ||
height: 50, | ||
width: 50, | ||
marginRight: 25, | ||
}, | ||
}, | ||
}); | ||
|
||
export const IconSvgFactoryExample: React.FunctionComponent = () => { | ||
return ( | ||
<div className={rootClass}> | ||
<OneDriveIcon /> | ||
<YammerIcon /> | ||
<BorderBlindsIcon color3="pink" /> | ||
</div> | ||
); | ||
}; |
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 |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
registry=https://registry.npmjs.org/ | ||
|
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'], | ||
}; |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
import { addons } from '@storybook/addons'; | ||
|
||
addons.setConfig({ | ||
showPanel: true, | ||
panelPosition: 'right', | ||
}); |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
import generateStoriesFromExamples from '@uifabric/build/storybook/generateStoriesFromExamples'; | ||
import { configure, addParameters, addDecorator } from '@storybook/react'; | ||
import { withA11y } from '@storybook/addon-a11y'; | ||
|
||
addDecorator(withA11y()); | ||
addParameters({ | ||
a11y: { | ||
manual: true, | ||
}, | ||
}); | ||
|
||
const req = require.context('../src/components', 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); |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
@fluentui/react-icons | ||
|
||
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 Fluent UI React is subject to the terms listed at https://aka.ms/fluentui-assets-license |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
# @fluentui/react-icons | ||
|
||
**Icon components for [Fluent UI React](https://developer.microsoft.com/en-us/fluentui)** | ||
|
||
This package provides utilities for creating svg icons, as well as set of customizable Icons. | ||
|
||
To import ReactIcons components: | ||
|
||
```js | ||
import { ComponentName } from '@fluentui/react-icons'; | ||
``` |
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() }); |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
let { createConfig, resolveMergeStylesSerializer } = require('@uifabric/build/jest/jest-resources'); | ||
let path = require('path'); | ||
|
||
const config = createConfig({ | ||
setupFiles: [path.resolve(path.join(__dirname, 'config', 'tests.js'))], | ||
|
||
moduleNameMapper: {}, | ||
|
||
snapshotSerializers: [resolveMergeStylesSerializer()], | ||
}); | ||
|
||
module.exports = config; |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
const { preset } = require('@uifabric/build'); | ||
|
||
preset(); |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,60 @@ | ||
{ | ||
"name": "@fluentui/react-icons", | ||
"version": "0.1.0", | ||
"description": "React components for building web experiences.", | ||
"private": true, | ||
"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", | ||
"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": { | ||
"@types/enzyme": "3.10.3", | ||
"@types/enzyme-adapter-react-16": "1.0.3", | ||
"@types/es6-promise": "0.0.32", | ||
"@types/jest": "~24.9.0", | ||
"@types/react": "16.8.11", | ||
"@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/tslint-rules": "^7.1.2", | ||
"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", | ||
"typescript-plugin-css-modules": "^2.2.0" | ||
}, | ||
"dependencies": { | ||
"@uifabric/set-version": "^7.0.9", | ||
"@uifabric/utilities": "^7.15.5", | ||
"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" | ||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
import * as React from 'react'; | ||
import createSvgIconWithRoot from '../utils/createSvgIconWithRoot'; | ||
import { mergeStyles } from 'office-ui-fabric-react/src/Styling'; | ||
|
||
const BorderBlindsIcon = createSvgIconWithRoot<{ color1?: string; color2?: string; color3?: string }>({ | ||
children: ({ classes, props, processedRootProps }) => { | ||
const { color1 = 'red', color2 = 'green', color3 = 'blue' } = props; | ||
|
||
// custom styles for the border blinds | ||
const borderBlindsPart1 = mergeStyles({ | ||
fill: color1, | ||
}); | ||
const borderBlindsPart2 = mergeStyles({ | ||
fill: color2, | ||
}); | ||
const borderBlindsPart3 = mergeStyles({ | ||
fill: color3, | ||
}); | ||
|
||
return ( | ||
<span {...processedRootProps}> | ||
<svg viewBox="0 0 40 40" className={classes.svg}> | ||
<g transform="scale(0.03125 0.03125)"> | ||
<path className={borderBlindsPart1} d="M0 192l320-128v768l-320 128z" /> | ||
<path className={borderBlindsPart2} d="M384 32l320 192v736l-320-160z" /> | ||
<path className={borderBlindsPart3} d="M768 224l256-192v768l-256 192z" /> | ||
</g> | ||
</svg> | ||
</span> | ||
); | ||
}, | ||
displayName: 'BorderBlindsIcon', | ||
}); | ||
|
||
export default BorderBlindsIcon; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Have we discussed whether we want to use default or named exports in new code? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Not really, I just used whatever I was used to :S Let me know what makes more sense and will update it.. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Original thinking with not exporting default was: A downstream index.ts file might do something like: export * from './BorderBlindsIcon'; Which would not include the default export, but only named ones. That said, we have seen concerns multiple times about So my 2c is "it's fine". |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
import * as React from 'react'; | ||
import createSvgIcon from '../utils/createSvgIcon'; | ||
|
||
const OneDriveIcon = createSvgIcon({ | ||
svg: ({ classes }) => ( | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Minor suggestion/thought: will there ever be more than 1 class name here? Maybe it should just be className. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. In our experience with react-icons-northstar there are cases like this, so would rather leave it as is at this moment as it is easier for extending this way and won't introduce necessity for changes in all icons in the future.. |
||
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0,0,2048,2048" className={classes.svg}> | ||
<g fill="#1B559B"> | ||
<path d="M 1860 1196 q 53 10 94 37 q 18 12 35 29 q 16 16 30 40 q 13 23 21 53 q 8 30 8 68 q 0 37 -10 75 q -11 38 -34 69 q -23 31 -58 51 q -36 20 -86 20 h -1079 q -78 0 -131 -24 q -54 -25 -87 -65 q -34 -40 -49 -91 q -15 -52 -15 -107 q 0 -46 12 -81 q 11 -35 31 -61 q 19 -27 43 -45 q 24 -19 50 -31 q 60 -29 136 -35 q 0 -1 4 -26 q 3 -25 16 -61 q 12 -37 36 -80 q 24 -43 64 -79 q 39 -37 98 -61 q 59 -25 141 -25 q 57 0 103 15 q 45 15 81 38 q 35 23 62 52 q 26 28 44 55 q 18 -10 42 -18 q 20 -7 48 -12 q 27 -6 60 -6 q 40 0 91 15 q 50 14 94 48 q 44 33 75 88 q 30 55 30 136 m -1463 174 q 0 53 10 99 q 10 46 29 86 h -170 q -52 0 -100 -23 q -48 -23 -85 -61 q -37 -38 -59 -87 q -22 -50 -22 -104 q 0 -49 11 -87 q 10 -38 27 -66 q 17 -29 39 -49 q 21 -21 44 -35 q 53 -33 121 -41 q -1 -9 -1 -18 q -1 -9 -1 -17 q 0 -72 27 -134 q 27 -63 73 -110 q 45 -47 106 -74 q 60 -27 127 -27 q 36 0 66 7 q 29 6 51 14 q 25 10 45 21 q 27 -48 65 -89 q 37 -41 84 -71 q 46 -30 101 -47 q 55 -17 115 -17 q 39 0 80 8 q 41 7 83 24 q 72 28 121 71 q 49 42 81 90 q 32 47 49 94 q 16 46 22 82 q -23 2 -43 5 q -21 3 -40 8 q -66 -69 -148 -104 q -82 -36 -177 -36 q -76 0 -136 17 q -60 17 -106 45 q -47 28 -81 64 q -34 36 -58 75 q -24 38 -39 76 q -15 37 -23 67 q -51 12 -102 38 q -52 26 -93 68 q -42 42 -67 101 q -26 59 -26 137" /> | ||
</g> | ||
</svg> | ||
), | ||
displayName: 'OneDriveIcon', | ||
}); | ||
|
||
export default OneDriveIcon; |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
import * as React from 'react'; | ||
import createSvgIcon from '../utils/createSvgIcon'; | ||
|
||
const YammerIcon = createSvgIcon({ | ||
svg: ({ classes }) => ( | ||
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0,0,2048,2048" className={classes.svg}> | ||
<g> | ||
<path d="M 1887 888 q 33 8 54 34 q 21 26 21 61 q 0 35 -22 62 q -23 26 -57 31 q -57 0 -121 -2 q -64 -3 -128 -7 q -64 -5 -122 -11 q -59 -7 -104 -16 q -45 -9 -72 -20 q -27 -12 -27 -26 q 0 -13 37 -26 q 37 -13 94 -24 q 57 -12 126 -22 q 68 -11 131 -18 q 63 -8 112 -12 q 48 -4 66 -4 m -163 549 q 17 14 26 34 q 9 20 9 41 q 0 21 -8 39 q -8 17 -21 30 q -14 13 -31 20 q -17 7 -36 7 q -10 0 -18 -2 q -8 -2 -19 -8 q -15 -8 -54 -34 q -39 -26 -88 -61 q -50 -35 -104 -76 q -54 -41 -98 -78 q -45 -37 -74 -67 q -29 -30 -29 -44 q 0 -8 9 -10 q 8 -3 19 -3 q 22 0 57 9 q 34 9 77 25 q 42 15 91 36 q 48 20 98 44 q 50 23 100 49 q 49 25 94 49 m 0 -901 q -67 37 -144 75 q -77 38 -149 69 q -73 30 -132 50 q -60 19 -93 19 q -11 0 -19 -2 q -8 -3 -8 -10 q 0 -14 29 -44 q 29 -30 74 -67 q 44 -38 98 -78 q 54 -41 104 -76 q 49 -36 88 -62 q 39 -26 54 -34 q 11 -6 20 -8 q 8 -2 18 -2 q 18 0 36 8 q 17 7 30 20 q 13 12 21 30 q 8 17 8 38 q 0 21 -9 41 q -9 19 -26 33 m -1191 823 l -430 -1051 q -6 -16 -6 -33 q 0 -20 8 -38 q 7 -19 21 -33 q 13 -15 33 -24 q 19 -9 42 -9 q 30 0 56 16 q 26 16 40 44 l 343 866 h 4 l 326 -860 q 11 -29 37 -46 q 25 -18 56 -18 q 22 0 40 9 q 18 8 31 22 q 13 13 21 31 q 7 17 7 36 q 0 14 -5 31 l -462 1154 q -30 74 -62 136 q -32 62 -76 107 q -44 44 -105 69 q -62 24 -151 24 q -28 0 -57 -2 q -30 -3 -54 -12 q -24 -10 -39 -28 q -16 -19 -16 -52 q 0 -21 8 -38 q 8 -17 21 -29 q 13 -12 30 -18 q 17 -6 35 -6 q 1 0 9 1 q 7 0 17 1 q 10 0 19 1 q 9 0 14 0 q 48 0 84 -15 q 36 -15 65 -46 q 28 -31 51 -78 q 22 -48 45 -112" /> | ||
</g> | ||
</svg> | ||
), | ||
displayName: 'YammerIcon', | ||
}); | ||
|
||
export default YammerIcon; |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
import './version'; | ||
|
||
export { default as createSvgIcon } from './utils/createSvgIcon'; | ||
export { default as createSvgIconWithRoot } from './utils/createSvgIconWithRoot'; | ||
|
||
export { default as OneDriveIcon } from './components/OneDriveIcon'; | ||
export { default as YammerIcon } from './components/YammerIcon'; | ||
export { default as BorderBlindsIcon } from './components/BorderBlindsIcon'; |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
import { IIconStyleProps } from './Icon.types'; | ||
import { ISvgIconStyles } from './SvgIcon.types'; | ||
import { mergeStyleSets } from 'office-ui-fabric-react/lib/Styling'; | ||
|
||
/** Class names used in themeable and non-themeable Icon components */ | ||
export const classes = mergeStyleSets({ | ||
root: {}, | ||
svg: { | ||
height: '100%', | ||
width: '100%', | ||
}, | ||
}); | ||
|
||
/** Class name used only in non-themeable Icon components */ | ||
export const MS_ICON = 'ms-Icon'; | ||
|
||
export const getStyles = (props: IIconStyleProps): ISvgIconStyles => { | ||
const { className, iconClassName, styles } = props; | ||
|
||
return { | ||
root: [classes.root, iconClassName, className, styles && styles.root], | ||
svg: [classes.svg], | ||
}; | ||
}; |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
import * as React from 'react'; | ||
import { IStyle } from 'office-ui-fabric-react/lib/Styling'; | ||
|
||
// TODO: Do we want to align APIs for the SvgIconProps in both versions? | ||
export interface ISvgIconProps extends React.HTMLAttributes<HTMLElement> { | ||
/** | ||
* Custom class to style the icon. | ||
*/ | ||
className?: string; | ||
} | ||
|
||
export interface ISvgIconStyles { | ||
root?: IStyle; | ||
svg?: IStyle; | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I would avoid class names to represent styles which could mutate frequently. Could we use inline styles or css variables?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
(don't let this block checkin, but I think it's important to get the right pattern to replicate.)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Added inline styles for now. Anyway in the next PR this icon will be remomved, so wouldn't like to spend much time on it..