Skip to content

Commit

Permalink
Merge pull request #425 from phase2/feature/controller-docs
Browse files Browse the repository at this point in the history
feat(updates): Documentation and Storybook updates.
  • Loading branch information
himerus authored Sep 7, 2023
2 parents fd4332f + 5519672 commit 3005e66
Show file tree
Hide file tree
Showing 14 changed files with 434 additions and 363 deletions.
2 changes: 1 addition & 1 deletion .storybook/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ module.exports = {
modernInlineRender: true,
},
framework: {
name: '@storybook/web-components-vite',
name: getAbsolutePath('@storybook/web-components-vite'),
options: {},
},
docs: {
Expand Down
14 changes: 7 additions & 7 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -90,12 +90,12 @@
"@commitlint/cli": "^17.4.0",
"@commitlint/config-conventional": "^17.4.0",
"@open-wc/testing": "^3.0.0-next.2",
"@storybook/addon-actions": "^7.3.0",
"@storybook/addon-docs": "^7.3.2",
"@storybook/addon-essentials": "^7.3.0",
"@storybook/addon-links": "^7.3.0",
"@storybook/web-components": "^7.3.0",
"@storybook/web-components-vite": "^7.3.0",
"@storybook/addon-actions": "^7.4.0",
"@storybook/addon-docs": "^7.4.0",
"@storybook/addon-essentials": "^7.4.0",
"@storybook/addon-links": "^7.4.0",
"@storybook/web-components": "^7.4.0",
"@storybook/web-components-vite": "^7.4.0",
"@types/estree": "^0.0.47",
"@typescript-eslint/eslint-plugin": "^5.0.0",
"@typescript-eslint/parser": "^5.0.0",
Expand Down Expand Up @@ -131,7 +131,7 @@
"react-syntax-highlighter": "^15.5.0",
"rimraf": "^3.0.2",
"rsync": "^0.6.1",
"storybook": "^7.3.0",
"storybook": "^7.4.0",
"svgo": "^2.8.0",
"tailwindcss": "3.0.0",
"ts-lit-plugin": "^1.2.1",
Expand Down
14 changes: 14 additions & 0 deletions packages/components/@deprecated/outline-form/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,19 @@
# @phase2/outline-form

## 0.1.6

### Patch Changes

- Updated dependencies
- @phase2/outline-controller-light-dom-styles[email protected]

## 0.1.5

### Patch Changes

- Updated dependencies
- @phase2/outline-controller-light-dom-styles[email protected]

## 0.1.4

### Patch Changes
Expand Down
4 changes: 2 additions & 2 deletions packages/components/@deprecated/outline-form/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@phase2/outline-form",
"version": "0.1.4",
"version": "0.1.6",
"description": "The Outline Components for the form component",
"keywords": [
"outline components",
Expand Down Expand Up @@ -29,7 +29,7 @@
},
"dependencies": {
"@phase2/outline-core": "^0.2.5",
"@phase2/outline-controller-light-dom-styles-controller": "^0.0.2",
"@phase2/outline-controller-light-dom-styles-controller": "^0.0.4",
"lit": "^2.3.1",
"tslib": "^2.1.0"
},
Expand Down
12 changes: 12 additions & 0 deletions packages/controllers/@deprecated/light-dom-styles/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,17 @@
# @phase2/outline-controller-light-dom-styles-controller

## 0.0.4

### Patch Changes

- Documentation Updates

## 0.0.3

### Patch Changes

- Documentation updates

## 0.0.2

### Patch Changes
Expand Down
2 changes: 2 additions & 0 deletions packages/controllers/@deprecated/light-dom-styles/README.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
[![Latest version for outline-controller-light-dom-styles-controller](https://img.shields.io/npm/v/@phase2/outline-controller-light-dom-styles-controller)](https://www.npmjs.com/package/@phase2/outline-controller-light-dom-styles-controller)

# `LightDomStyles` Controller

> This controller is deprecated, and the `StyleController` from `@phase2/outline-controller-style-controller` should be utilized in its place when possible.
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@phase2/outline-controller-light-dom-styles-controller",
"version": "0.0.2",
"version": "0.0.4",
"description": "Deprecated controller to manage styles via Light DOM.",
"keywords": [
"outline components",
Expand Down
18 changes: 18 additions & 0 deletions packages/controllers/adopted-stylesheets/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,23 @@
# @phase2/outline-adopted-stylesheets-controller

## 0.0.4

### Patch Changes

- Documentation Updates

## 0.0.3

### Patch Changes

- Documentation Update

## 0.0.2

### Patch Changes

- Documentation updates

## 0.0.1

### Patch Changes
Expand Down
35 changes: 24 additions & 11 deletions packages/controllers/adopted-stylesheets/README.md
Original file line number Diff line number Diff line change
@@ -1,40 +1,53 @@
# AdoptedStyleSheets Controller
# `AdoptedStylesheets` Controller

The `AdoptedStyleSheets` controller is a part of the `@phase2/outline-adopted-stylesheets-controller` package. This controller helps components attach "global" document styles without duplication at the component level as well as de-duping any previous inclusions into `AdoptedStyleSheets`.
[![Latest version for outline-adopted-stylesheets-controller](https://img.shields.io/npm/v/@phase2/outline-adopted-stylesheets-controller)](https://www.npmjs.com/package/@phase2/outline-adopted-stylesheets-controller)

> The `AdoptedStylesheets` controller is a part of the `@phase2/outline-adopted-stylesheets-controller` package. This controller helps components attach "global" document styles without duplication at the component level as well as de-duping any previous inclusions into `AdoptedStylesheets`.
## Installing the `AdoptedStylesheets` Controller

Install the new package:

```bash
yarn add @phase2/outline-adopted-stylesheets-controller
```

## Overview

Adopted stylesheets are a way to apply styles to a document or a shadow root. They are a part of the CSS Shadow Parts specification. You can read more about them [here](https://wicg.github.io/construct-stylesheets/).
Adopted stylesheets are a method to apply styles to a document or a shadow root. They are a part of the CSS Shadow Parts specification. Unfortunately, the original documentation link is no longer available. However, you can find more information about adopted stylesheets and their usage in web components in the following resources:

- [MDN Web Docs: Document adoptedStyleSheets](https://developer.mozilla.org/en-US/docs/Web/API/Document/adoptedStyleSheets): This documentation provides an in-depth look at the `adoptedStyleSheets` property of the `Document` interface.
- [MDN Web Docs: ShadowRoot adoptedStyleSheets](https://developer.mozilla.org/en-US/docs/Web/API/ShadowRoot/adoptedStyleSheets): This documentation provides an in-depth look at the `adoptedStyleSheets` property of the `ShadowRoot` interface.

## Methods

The `AdoptedStyleSheets` controller provides the following methods:
The `AdoptedStylesheets` controller provides the following methods:

- `constructor(globalStyles: CSSResult)`: This method is used to create a new instance of the `AdoptedStyleSheets` controller. It takes a `CSSResult` object as a parameter, which represents the global styles to be adopted.
- `constructor(globalStyles: CSSResult)`: This method is used to create a new instance of the `AdoptedStylesheets` controller. It takes a `CSSResult` object as a parameter, which represents the global styles to be adopted.

- `hostConnected()`: This method is called when the host element is connected to the DOM. It adds the document's stylesheet to the adopted stylesheets if it is not already present.

- `hostDisconnected()`: This method is called when the host element is disconnected from the DOM. It removes the document's stylesheet from the adopted stylesheets if it is present.

## Usage

Here is an example of how to use the `AdoptedStyleSheets` controller in a component:
Here is an example of how to use the `AdoptedStylesheets` controller in a component:

```typescript
import { AdoptedStyleSheets } from '@phase2/outline-adopted-stylesheets-controller';
import { AdoptedStylesheets } from '@phase2/outline-adopted-stylesheets-controller';
import { css, CSSResult } from 'lit';
import { OutlineElement } from '@phase2/outline-core';
import globalStyles from './my-component.lightDom.css.lit';

class MyComponent extends OutlineElement {
adoptedStylesheets: AdoptedStyleSheets;
AdoptedStylesheets: AdoptedStylesheets;

connectedCallback() {
super.connectedCallback();
this.adoptedStylesheets = new AdoptedStyleSheets(globalStyles);
this.addController(this.adoptedStylesheets);
this.AdoptedStylesheets = new AdoptedStylesheets(globalStyles);
this.addController(this.AdoptedStylesheets);
}
}
```

In the provided example, the `connectedCallback` method is utilized. This method is invoked whenever the element is inserted into the DOM. Within this method, an instance of `AdoptedStyleSheets` is created and added as a controller. This is a more efficient approach than creating the instance and adding the controller within the `constructor`. The reason for this is that it delays these operations until the element is actually inserted into the DOM. If there are many such elements that are created but not immediately added to the DOM, this approach can significantly improve the startup performance of your application. Therefore, the `connectedCallback` method is a crucial part of managing the lifecycle of a web component, especially when dealing with adopted stylesheets.
In the provided example, the `connectedCallback` method is utilized. This method is invoked whenever the element is inserted into the DOM. Within this method, an instance of `AdoptedStylesheets` is created and added as a controller. This is a more efficient approach than creating the instance and adding the controller within the `constructor`. The reason for this is that it delays these operations until the element is actually inserted into the DOM. If there are many such elements that are created but not immediately added to the DOM, this approach can significantly improve the startup performance of your application. Therefore, the `connectedCallback` method is a crucial part of managing the lifecycle of a web component, especially when dealing with adopted stylesheets.
2 changes: 1 addition & 1 deletion packages/controllers/adopted-stylesheets/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@phase2/outline-adopted-stylesheets-controller",
"version": "0.0.1",
"version": "0.0.4",
"description": "Controller to help with managing native AdoptedStylesheet implementations.",
"keywords": [
"outline components",
Expand Down
6 changes: 6 additions & 0 deletions packages/documentation/outline-storybook/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,11 @@
# @phase2/outline-storybook

## 0.1.1

### Patch Changes

- Documentation updates

## 0.1.0

### Minor Changes
Expand Down
2 changes: 1 addition & 1 deletion packages/documentation/outline-storybook/config/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ module.exports = {
modernInlineRender: true,
},
framework: {
name: '@storybook/web-components-vite',
name: getAbsolutePath('@storybook/web-components-vite'),
options: {},
},
docs: {
Expand Down
2 changes: 1 addition & 1 deletion packages/documentation/outline-storybook/package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "@phase2/outline-storybook",
"description": "Storybook integration for Outline",
"version": "0.1.0",
"version": "0.1.1",
"license": "MIT",
"scripts": {
"package": "yarn publish"
Expand Down
Loading

0 comments on commit 3005e66

Please sign in to comment.