-
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.
react-divider: Migrate to new DX (#18625)
#### Pull request checklist - [x] Addresses an existing issue: Fixes part of #18579 - [x] Include a change request file using `$ yarn change` #### Description of changes - migrates the `react-divider` package to new DX using `nx workspace-generator migrate-converged-pkg`
- Loading branch information
1 parent
463d467
commit d222fbc
Showing
16 changed files
with
154 additions
and
32 deletions.
There are no files selected for viewing
7 changes: 7 additions & 0 deletions
7
change/@fluentui-react-divider-0094a310-de20-40b5-9518-a3b7bee1aa91.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,7 @@ | ||
{ | ||
"type": "prerelease", | ||
"comment": "Divider: Migrate react-divider to new DX.", | ||
"packageName": "@fluentui/react-divider", | ||
"email": "[email protected]", | ||
"dependentChangeType": "patch" | ||
} |
7 changes: 7 additions & 0 deletions
7
change/@fluentui-react-examples-a33dafc0-fc68-4afd-94d8-467f1209faf4.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,7 @@ | ||
{ | ||
"type": "patch", | ||
"comment": "Removing @fluentui/react-divider stories from @fluentui/react-examples.", | ||
"packageName": "@fluentui/react-examples", | ||
"email": "[email protected]", | ||
"dependentChangeType": "patch" | ||
} |
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,11 @@ | ||
const rootMain = require('../../../.storybook/main'); | ||
|
||
module.exports = /** @type {Pick<import('../../../.storybook/main').StorybookConfig,'addons'|'stories'|'webpackFinal'>} */ ({ | ||
stories: [...rootMain.stories, '../src/**/*.stories.mdx', '../src/**/*.stories.@(ts|tsx)'], | ||
addons: [...rootMain.addons], | ||
webpackFinal: (config, options) => { | ||
const localConfig = { ...rootMain.webpackFinal(config, options) }; | ||
|
||
return localConfig; | ||
}, | ||
}); |
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 @@ | ||
import * as rootPreview from '../../../.storybook/preview'; | ||
|
||
export const decorators = [...rootPreview.decorators]; |
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 @@ | ||
{ | ||
"extends": "../tsconfig.json", | ||
"compilerOptions": { | ||
"allowJs": true, | ||
"checkJs": true | ||
}, | ||
"exclude": ["../**/*.test.ts", "../**/*.test.js", "../**/*.test.tsx", "../**/*.test.jsx"], | ||
"include": ["../src/**/*", "*.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,5 @@ | ||
{ | ||
"$schema": "https://developer.microsoft.com/json-schemas/api-extractor/v7/api-extractor.schema.json", | ||
"extends": "./api-extractor.json", | ||
"mainEntryPointFilePath": "<projectFolder>/dist/<unscopedPackageName>/src/index.d.ts" | ||
} |
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 |
---|---|---|
@@ -1,9 +1,21 @@ | ||
const { createConfig } = require('@fluentui/scripts/jest/jest-resources'); | ||
const path = require('path'); | ||
// @ts-check | ||
|
||
const config = createConfig({ | ||
setupFiles: [path.resolve(path.join(__dirname, 'config', 'tests.js'))], | ||
/** | ||
* @type {jest.InitialOptions} | ||
*/ | ||
module.exports = { | ||
displayName: 'react-divider', | ||
preset: '../../jest.preset.js', | ||
globals: { | ||
'ts-jest': { | ||
tsConfig: '<rootDir>/tsconfig.json', | ||
diagnostics: false, | ||
}, | ||
}, | ||
transform: { | ||
'^.+\\.tsx?$': 'ts-jest', | ||
}, | ||
coverageDirectory: './coverage', | ||
setupFilesAfterEnv: ['./config/tests.js'], | ||
snapshotSerializers: ['@fluentui/jest-serializer-make-styles'], | ||
}); | ||
|
||
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
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,62 @@ | ||
// | ||
// !!! A temporary workaround to avoid dependencies on any icon packages. | ||
// !!! A usage of converged icon package should be considered. | ||
// !!! Used for converged stories to avoid dependencies on non-converged icons | ||
// | ||
|
||
import * as React from 'react'; | ||
import { mergeClasses, makeStyles } from '@fluentui/react-make-styles'; | ||
import { getNativeProps, htmlElementProperties } from '@fluentui/react-utilities'; | ||
|
||
const useStyles = makeStyles({ | ||
root: { | ||
display: 'inline-block', | ||
verticalAlign: 'middle', | ||
speak: 'none', | ||
width: '1em', | ||
height: '1em', | ||
}, | ||
svg: { | ||
height: '100%', | ||
fill: 'currentColor', | ||
verticalAlign: 'top', | ||
}, | ||
}); | ||
|
||
const useIconProps = (props: React.HTMLAttributes<HTMLSpanElement>) => { | ||
const containerProps = props['aria-label'] | ||
? {} | ||
: { | ||
role: 'presentation', | ||
['aria-hidden']: true, | ||
}; | ||
const nativeProps = getNativeProps<React.HTMLAttributes<HTMLElement>>(props, htmlElementProperties); | ||
const styles = useStyles(); | ||
|
||
const rootClasses = styles.root; | ||
const svgClasses = styles.svg; | ||
|
||
return { containerProps, nativeProps, rootClasses, svgClasses }; | ||
}; | ||
|
||
export const renderIcon = ( | ||
SVGElement: (props: { svgClasses: string }) => JSX.Element, | ||
): React.FC<React.HTMLAttributes<HTMLSpanElement>> => props => { | ||
const { containerProps, nativeProps, rootClasses, svgClasses } = useIconProps(props); | ||
|
||
return React.createElement( | ||
'span', | ||
{ | ||
...containerProps, | ||
...nativeProps, | ||
className: mergeClasses(rootClasses, props.className), | ||
}, | ||
<SVGElement svgClasses={svgClasses} />, | ||
); | ||
}; | ||
|
||
export const ClockIcon = renderIcon(props => ( | ||
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 2048 2048" className={props.svgClasses} focusable="false"> | ||
<path d="M1024 2048q-124 0-238-32t-214-90-181-140-140-181-91-214-32-239q0-124 32-238t90-214 140-181 181-140 214-91 239-32q124 0 238 32t214 90 181 140 140 181 91 214 32 239q0 124-32 238t-90 214-140 181-181 140-214 91-239 32zm0-1664q-159 0-298 60T482 609 317 853t-61 299q0 159 60 298t165 244 244 165 299 61q159 0 298-60t244-165 165-244 61-299q0-159-60-298t-165-244-244-165-299-61zm0 768V640H896v640h512v-128h-384z" /> | ||
</svg> | ||
)); |
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 |
---|---|---|
@@ -1,22 +1,17 @@ | ||
{ | ||
"extends": "../../tsconfig.base.json", | ||
"include": ["src"], | ||
"compilerOptions": { | ||
"baseUrl": ".", | ||
"target": "ES5", | ||
"module": "CommonJS", | ||
"lib": ["es5", "dom"], | ||
"outDir": "dist", | ||
"target": "es5", | ||
"module": "commonjs", | ||
"jsx": "react", | ||
"declaration": true, | ||
"sourceMap": true, | ||
"experimentalDecorators": true, | ||
"importHelpers": true, | ||
"noUnusedLocals": true, | ||
"forceConsistentCasingInFileNames": true, | ||
"strict": true, | ||
"moduleResolution": "node", | ||
"preserveConstEnums": true, | ||
"lib": ["es5", "dom"], | ||
"skipLibCheck": true, | ||
"typeRoots": ["../../node_modules/@types", "../../typings"], | ||
"types": ["jest", "custom-global"] | ||
}, | ||
"include": ["src"] | ||
"types": ["jest", "custom-global", "inline-style-expand-shorthand"] | ||
} | ||
} |
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