Skip to content

Commit

Permalink
react-checkbox: Migration to new DX (#19063)
Browse files Browse the repository at this point in the history
* Merge to new DX

* Change files
  • Loading branch information
tringakrasniqi authored Jul 23, 2021
1 parent dfe3969 commit 17c38c1
Show file tree
Hide file tree
Showing 15 changed files with 87 additions and 29 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"type": "none",
"comment": "Merge to new DX",
"packageName": "@fluentui/react-checkbox",
"email": "[email protected]",
"dependentChangeType": "none"
}
1 change: 1 addition & 0 deletions jest.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -33,5 +33,6 @@ module.exports = {
'<rootDir>/packages/react-shared-contexts',
'<rootDir>/packages/react-tooltip',
'<rootDir>/packages/react-card',
'<rootDir>/packages/react-checkbox',
],
};
2 changes: 1 addition & 1 deletion nx.json
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@
"@fluentui/react-card": { "tags": ["vNext", "platform:web"], "implicitDependencies": [] },
"@fluentui/react-cards": { "implicitDependencies": [] },
"@fluentui/react-charting": { "implicitDependencies": [] },
"@fluentui/react-checkbox": { "implicitDependencies": [] },
"@fluentui/react-checkbox": { "tags": ["vNext", "platform:web"], "implicitDependencies": [] },
"@fluentui/react-components": { "implicitDependencies": [] },
"@fluentui/react-compose": { "implicitDependencies": [] },
"@fluentui/react-conformance": { "implicitDependencies": [] },
Expand Down
11 changes: 11 additions & 0 deletions packages/react-checkbox/.storybook/main.js
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;
},
});
7 changes: 7 additions & 0 deletions packages/react-checkbox/.storybook/preview.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
import * as rootPreview from '../../../.storybook/preview';

/** @type {typeof rootPreview.decorators} */
export const decorators = [...rootPreview.decorators];

/** @type {typeof rootPreview.parameters} */
export const parameters = { ...rootPreview.parameters };
9 changes: 9 additions & 0 deletions packages/react-checkbox/.storybook/tsconfig.json
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"]
}
1 change: 1 addition & 0 deletions packages/react-checkbox/config/api-extractor.json
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
{
"$schema": "https://developer.microsoft.com/json-schemas/api-extractor/v7/api-extractor.schema.json",
"extends": "@fluentui/scripts/api-extractor/api-extractor.common.json"
}
5 changes: 5 additions & 0 deletions packages/react-checkbox/config/api-extractor.local.json
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"
}
26 changes: 19 additions & 7 deletions packages/react-checkbox/jest.config.js
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-checkbox',
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;
};
9 changes: 5 additions & 4 deletions packages/react-checkbox/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,11 @@
"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-snapshots": "just-scripts jest -u"
"start": "yarn storybook",
"test": "jest",
"docs": "api-extractor run --config=config/api-extractor.local.json --local",
"build:local": "tsc -p . --module esnext --emitDeclarationOnly && node ../../scripts/typescript/normalize-import --output dist/react-checkbox/src && yarn docs",
"storybook": "start-storybook"
},
"devDependencies": {
"@fluentui/eslint-plugin": "^1.3.2",
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import * as React from 'react';
import { Checkbox } from '@fluentui/react-checkbox';
import { Checkbox } from './index';

// TODO add 'react-checkbox' to the list for withFluentProvider in react-examples/.storybook/preview.js

Expand All @@ -8,3 +8,8 @@ export const CheckboxExample = () => (
<Checkbox>Hello World!</Checkbox>
</>
);

export default {
title: 'Components/Checkbox',
component: Checkbox,
};
21 changes: 8 additions & 13 deletions packages/react-checkbox/tsconfig.json
Original file line number Diff line number Diff line change
@@ -1,22 +1,17 @@
{
"extends": "../../tsconfig.base.json",
"include": ["src"],
"compilerOptions": {
"baseUrl": ".",
"target": "ES2015",
"module": "CommonJS",
"lib": ["ES2015", "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", "storybook__addons"]
}
}
1 change: 0 additions & 1 deletion packages/react-examples/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,6 @@
"@fluentui/react": "^8.23.8",
"@fluentui/react-cards": "^0.200.4",
"@fluentui/react-charting": "^5.3.14",
"@fluentui/react-checkbox": "^9.0.0-alpha.14",
"@fluentui/react-components": "^9.0.0-alpha.83",
"@fluentui/react-docsite-components": "^8.3.3",
"@fluentui/react-experiments": "^8.1.45",
Expand Down
3 changes: 2 additions & 1 deletion tsconfig.base.json
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,8 @@
"@fluentui/react-slider": ["packages/react-slider/src/index.ts"],
"@fluentui/make-styles-webpack-loader": ["packages/make-styles-webpack-loader/src/index.ts"],
"@fluentui/react-avatar": ["packages/react-avatar/src/index.ts"],
"@fluentui/react-card": ["packages/react-card/src/index.ts"]
"@fluentui/react-card": ["packages/react-card/src/index.ts"],
"@fluentui/react-checkbox": ["packages/react-checkbox/src/index.ts"]
}
},
"exclude": ["node_modules"]
Expand Down
6 changes: 5 additions & 1 deletion workspace.json
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,11 @@
},
"@fluentui/react-cards": { "root": "packages/react-cards", "projectType": "library" },
"@fluentui/react-charting": { "root": "packages/react-charting", "projectType": "library" },
"@fluentui/react-checkbox": { "root": "packages/react-checkbox", "projectType": "library" },
"@fluentui/react-checkbox": {
"root": "packages/react-checkbox",
"projectType": "library",
"sourceRoot": "packages/react-checkbox/src"
},
"@fluentui/react-components": { "root": "packages/react-components", "projectType": "library" },
"@fluentui/react-compose": { "root": "packages/react-compose", "projectType": "library" },
"@fluentui/react-conformance": { "root": "packages/react-conformance", "projectType": "library" },
Expand Down

0 comments on commit 17c38c1

Please sign in to comment.