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.
feat(react-theme-sass): Add Sass variables mapped to CSS variables pr…
…ovided by react-theme (microsoft#22964) * add react-theme-sass package * add SASS variables * Change file * remove spec template * update yarn.lock after merge * update yarn.lock after merge * Replace node-sass with dart-sass, remove unused dependencies * Update .github/CODEOWNERS Co-authored-by: Justin Slone <[email protected]> Co-authored-by: Justin Slone <[email protected]>
- Loading branch information
Showing
34 changed files
with
990 additions
and
3 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
7 changes: 7 additions & 0 deletions
7
change/@fluentui-react-theme-sass-2b6d8ee9-5f41-4727-b1b6-c04d8339e80c.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": "Add SASS variables mapped to CSS variables provided by react-theme", | ||
"packageName": "@fluentui/react-theme-sass", | ||
"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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
{ | ||
"plugins": ["annotate-pure-calls", "@babel/transform-react-pure-annotations"] | ||
} |
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 @@ | ||
{ | ||
"extends": ["plugin:@fluentui/eslint-plugin/node"], | ||
"root": true | ||
} |
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,29 @@ | ||
.storybook/ | ||
.vscode/ | ||
bundle-size/ | ||
config/ | ||
coverage/ | ||
e2e/ | ||
etc/ | ||
node_modules/ | ||
src/ | ||
dist/types/ | ||
temp/ | ||
__fixtures__ | ||
__mocks__ | ||
__tests__ | ||
|
||
*.api.json | ||
*.log | ||
*.spec.* | ||
*.stories.* | ||
*.test.* | ||
*.yml | ||
|
||
# config files | ||
*config.* | ||
*rc.* | ||
.editorconfig | ||
.eslint* | ||
.git* | ||
.prettierignore |
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 @@ | ||
@fluentui/react-theme-sass | ||
|
||
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 |
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,35 @@ | ||
# @fluentui/react-theme-sass | ||
|
||
**React Theme Sass for [Fluent UI React](https://developer.microsoft.com/en-us/fluentui)** | ||
|
||
SASS variables referencing react-theme design tokens injected to DOM by react-provider. | ||
|
||
## Usage | ||
|
||
1. Instantiate a `FluentProvider` to inject a Fluent theme into a DOM: | ||
|
||
```jsx | ||
import React from 'react'; | ||
import ReactDOM from 'react-dom'; | ||
import { FluentProvider, teamsLightTheme } from '@fluentui/react-components'; | ||
import App from './App'; | ||
ReactDOM.render( | ||
<FluentProvider theme={teamsLightTheme}> | ||
<App /> | ||
</FluentProvider>, | ||
document.getElementById('root'), | ||
); | ||
``` | ||
|
||
2. In SCSS styles you can import SCSS variables from `@fluentui/react-theme-sass` and use them in the styles: | ||
|
||
```scss | ||
@import '~@fluentui/react-theme-sass'; | ||
.brandedElement { | ||
color: $colorBrandForeground1; | ||
background: $colorBrandBackground; | ||
border-radius: $borderRadiusLarge; | ||
} | ||
``` | ||
|
||
⚠ This package does not export any Javascript code.️ |
5 changes: 5 additions & 0 deletions
5
packages/react-components/react-theme-sass/config/api-extractor.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,5 @@ | ||
{ | ||
"$schema": "https://developer.microsoft.com/json-schemas/api-extractor/v7/api-extractor.schema.json", | ||
"extends": "@fluentui/scripts/api-extractor/api-extractor.common.v-next.json", | ||
"mainEntryPointFilePath": "<projectFolder>/dist/types/index.d.ts" | ||
} |
5 changes: 5 additions & 0 deletions
5
packages/react-components/react-theme-sass/config/api-extractor.local.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,5 @@ | ||
{ | ||
"$schema": "https://developer.microsoft.com/json-schemas/api-extractor/v7/api-extractor.schema.json", | ||
"extends": "./api-extractor.json", | ||
"mainEntryPointFilePath": "<projectFolder>/dist/types/packages/react-components/<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 |
---|---|---|
@@ -0,0 +1 @@ | ||
/** Jest test setup file. */ |
9 changes: 9 additions & 0 deletions
9
packages/react-components/react-theme-sass/etc/react-theme-sass.api.md
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 @@ | ||
## API Report File for "@fluentui/react-theme-sass" | ||
|
||
> Do not edit this file. It is a report generated by [API Extractor](https://api-extractor.com/). | ||
```ts | ||
|
||
// (No @packageDocumentation comment for this package) | ||
|
||
``` |
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,22 @@ | ||
// @ts-check | ||
|
||
/** | ||
* @type {import('@jest/types').Config.InitialOptions} | ||
*/ | ||
module.exports = { | ||
displayName: 'react-theme-sass', | ||
preset: '../../../jest.preset.js', | ||
globals: { | ||
'ts-jest': { | ||
tsConfig: '<rootDir>/tsconfig.spec.json', | ||
diagnostics: false, | ||
}, | ||
}, | ||
testEnvironment: 'jest-environment-node-single-context', | ||
transform: { | ||
'^.+\\.tsx?$': 'ts-jest', | ||
}, | ||
coverageDirectory: './coverage', | ||
setupFilesAfterEnv: ['./config/tests.js'], | ||
snapshotSerializers: ['@griffel/jest-serializer'], | ||
}; |
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 { preset } from '@fluentui/scripts'; | ||
|
||
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,39 @@ | ||
{ | ||
"name": "@fluentui/react-theme-sass", | ||
"version": "9.0.0-alpha.0", | ||
"description": "SASS variables referencing react-theme design tokens injected to DOM by react-provider.", | ||
"main": "lib-commonjs/index.js", | ||
"module": "lib/index.js", | ||
"typings": "dist/index.d.ts", | ||
"style": "sass/tokens.scss", | ||
"sideEffects": false, | ||
"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": "yarn storybook", | ||
"test": "jest --passWithNoTests", | ||
"docs": "api-extractor run --config=config/api-extractor.local.json --local", | ||
"build:local": "tsc -p ./tsconfig.lib.json --module esnext --emitDeclarationOnly && node ../../../scripts/typescript/normalize-import --output ./dist/types/packages/react-components/react-theme-sass/src && yarn docs", | ||
"storybook": "node ../../../scripts/storybook/runner", | ||
"type-check": "tsc -b tsconfig.json" | ||
}, | ||
"devDependencies": { | ||
"@fluentui/eslint-plugin": "*", | ||
"@fluentui/scripts": "^1.0.0" | ||
}, | ||
"beachball": { | ||
"disallowedChangeTypes": [ | ||
"major", | ||
"minor", | ||
"patch" | ||
] | ||
} | ||
} |
14 changes: 14 additions & 0 deletions
14
packages/react-components/react-theme-sass/sass/Sass.test.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 |
---|---|---|
@@ -0,0 +1,14 @@ | ||
import { compileString } from 'sass'; | ||
import { webLightTheme } from '@fluentui/react-theme'; | ||
|
||
describe('Sass tokens', () => { | ||
// by referencing all react-theme tokens as SCSS variables, verifies that all the variables are exported | ||
it('exist for all theme tokens', () => { | ||
const data = [ | ||
'@import "sass/tokens.scss";', | ||
...Object.keys(webLightTheme).map(tokenName => `$expected__${tokenName}: $${tokenName};`), | ||
].join('\n'); | ||
|
||
compileString(data, { loadPaths: ['.'] }); | ||
}); | ||
}); |
6 changes: 6 additions & 0 deletions
6
packages/react-components/react-theme-sass/sass/borderRadiusTokens.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,6 @@ | ||
$borderRadiusNone: var(--borderRadiusNone); | ||
$borderRadiusSmall: var(--borderRadiusSmall); | ||
$borderRadiusMedium: var(--borderRadiusMedium); | ||
$borderRadiusLarge: var(--borderRadiusLarge); | ||
$borderRadiusXLarge: var(--borderRadiusXLarge); | ||
$borderRadiusCircular: var(--borderRadiusCircular); |
Oops, something went wrong.