Skip to content
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

Add adaptive-ui package #5989

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"type": "minor",
"comment": "Add adaptive-ui package",
"packageName": "@microsoft/adaptive-ui",
"email": "[email protected]",
"dependentChangeType": "patch"
}
10 changes: 10 additions & 0 deletions packages/utilities/adaptive-ui/.eslintignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
# don't ever lint node_modules
node_modules
# don't lint build output (make sure it's set to your correct build folder name)
dist
# don't lint coverage output
coverage
# don't lint www
www
# don't lint test files
__test__
10 changes: 10 additions & 0 deletions packages/utilities/adaptive-ui/.eslintrc.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
{
"extends": ["@microsoft/eslint-config-fast-dna", "prettier"],
"rules": {
"@typescript-eslint/no-non-null-assertion": "off",
"import/extensions": [
"error",
"always"
]
}
}
3 changes: 3 additions & 0 deletions packages/utilities/adaptive-ui/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
tsdoc-metadata.json
temp
test
6 changes: 6 additions & 0 deletions packages/utilities/adaptive-ui/.mocharc.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"colors": true,
"recursive": true,
"timeout": 5000,
"spec": "test/**/*.spec.js"
}
10 changes: 10 additions & 0 deletions packages/utilities/adaptive-ui/.npmignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
# Tests
__test__/
*.spec.*
*.test.*

# Source files
src/

# babel config
babel.config.js
1 change: 1 addition & 0 deletions packages/utilities/adaptive-ui/.npmrc
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
package-lock=false
3 changes: 3 additions & 0 deletions packages/utilities/adaptive-ui/.prettierignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
dist/*
test/*
src/__test__/*
59 changes: 59 additions & 0 deletions packages/utilities/adaptive-ui/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
# Adaptive UI

Adaptive UI is a library for building highly-consistent design systems based around your visual decisions. This represents an evolution of many token implementations that provide end-result values without the means to track how they were derived or easily adjust them.

This is a core feature of [FAST](https://fast.design) and is incorporated into the [Fluent UI Web Components](https://aka.ms/fluentwebcomponents) and other design systems.

## Installation

```shell
npm install --save @microsoft/adaptive-ui
```

```shell
yarn add @microsoft/adaptive-ui
```

## Getting started

The most common way to use this library is through the `DesignToken`s.
bheston marked this conversation as resolved.
Show resolved Hide resolved

For example, in a FAST style sheet:

```ts
css`
:host {
background: ${neutralFillRest};
}
`
```

This will evaluate the `neutralFillRest` recipe when the component loads and apply the correct color appropriate for the current context within design.

Most of the color recipes are contextually aware of where they're used so they produce accessible colors based on the configuration of the design, for instance between light mode and dark mode, or when personalization is applied, like a blue tint to the neutral colors or orange accent color.

To tint the neutral palette, and thus all color recipes derived from it:

```ts
neutralBaseColor.withDefault("#73818C");
```

To switch to dark mode:

```ts
fillColor.withDefault("#232323");
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I thought this was supposed to be done with luminosity.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, good catch. I'm a bit torn here. I've added the layering system to the road map because I want to generalize it a bit more, but it would also be great to incorporate #5286. I've messaged Nick to confirm whether this is part of what he's working on right now.

For parity we could add exactly what we have now, it's just a bit hard to get the pieces working together correctly.

```

See more about the [adaptive color system](./src/color/README.md).

## Road map

The layer system for setting content area background colors and improved handling of light and dark mode is evolving and will be added soon.
bheston marked this conversation as resolved.
Show resolved Hide resolved

The latest version of adaptive density, currently in RFC and PR, will come here soon as well.

The color system is being updated to support opacity in colors, which will enable at least the neutral palette to overlay images or background blur effects like in Windows 11.

### Further afield

The fixed design tokens will evolve into a more configurable definition aligning with industry standards in design tokens.
4 changes: 4 additions & 0 deletions packages/utilities/adaptive-ui/api-extractor.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
{
"$schema": "https://developer.microsoft.com/json-schemas/api-extractor/v7/api-extractor.schema.json",
"extends": "../../../api-extractor.json"
}
Loading