-
Notifications
You must be signed in to change notification settings - Fork 211
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(rule): add Spectrum rule pattern and apply to docs
- Loading branch information
Showing
23 changed files
with
625 additions
and
64 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
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
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
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,72 @@ | ||
## Description | ||
|
||
`sp-rule` bring clarity to a layout by grouping and dividing content in close proximity. They can also be used to establish rhythm and hierarchy. | ||
|
||
### Installation | ||
|
||
[![See it on NPM!](https://img.shields.io/npm/v/@spectrum-web-components/rule?style=for-the-badge)](https://www.npmjs.com/package/@spectrum-web-components/rule) | ||
[![How big is this package in your project?](https://img.shields.io/bundlephobia/minzip/@spectrum-web-components/rule?style=for-the-badge)](https://bundlephobia.com/result?p=@spectrum-web-components/rule) | ||
|
||
``` | ||
npm install @spectrum-web-components/rule | ||
# or | ||
yarn add @spectrum-web-components/rule | ||
``` | ||
|
||
## Examples | ||
|
||
### Large | ||
|
||
```html-live | ||
<h2 class="spectrum-Heading--subtitle1">Large</h2> | ||
<sp-rule size="large"></sp-rule> | ||
<p class="spectrum-Body">Page or Section Titles.</p> | ||
``` | ||
|
||
### Medium | ||
|
||
```html-live | ||
<h3 class="spectrum-Heading--subtitle2">Medium</h3> | ||
<sp-rule size="medium"></sp-rule> | ||
<p class="spectrum-Body">Divide subsections, or divide different groups of elements (between panels, rails, etc.)</p> | ||
``` | ||
|
||
### Small | ||
|
||
```html-live | ||
<h4 class="spectrum-Heading--subtitle3">Small</h4> | ||
<sp-rule size="small"></sp-rule> | ||
<p class="spectrum-Body">Divide like-elements (tables, tool groups, elements within a panel, etc.)</p> | ||
``` | ||
|
||
### Vertical, Small | ||
|
||
When a vertical Rule is used inside of a flex container, use `align-self: stretch; height: auto;` on the Rule. | ||
|
||
```html-live | ||
<div style="height: 32px; display: flex;"> | ||
<sp-action-button quiet> | ||
<sp-icon slot="icon" size="m" name="ui:Magnifier"></sp-icon> | ||
</sp-action-button> | ||
<sp-rule size="small" vertical></sp-rule> | ||
<sp-action-button quiet> | ||
<sp-icon slot="icon" size="m" name="ui:Magnifier"></sp-icon> | ||
</sp-action-button> | ||
</div> | ||
``` | ||
|
||
### Vertical, Medium | ||
|
||
```html-live | ||
<div style="height: 32px; display: flex;"> | ||
<sp-action-button quiet> | ||
<sp-icon slot="icon" size="m" name="ui:Magnifier"></sp-icon> | ||
</sp-action-button> | ||
<sp-rule size="medium" vertical></sp-rule> | ||
<sp-action-button quiet> | ||
<sp-icon slot="icon" size="m" name="ui:Magnifier"></sp-icon> | ||
</sp-action-button> | ||
</div> | ||
``` |
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,46 @@ | ||
{ | ||
"name": "@spectrum-web-components/rule", | ||
"publishConfig": { | ||
"access": "public" | ||
}, | ||
"repository": { | ||
"type": "git", | ||
"url": "https://github.com/adobe/spectrum-web-components.git", | ||
"directory": "packages/rule" | ||
}, | ||
"bugs": { | ||
"url": "https://github.com/adobe/spectrum-web-components/issues" | ||
}, | ||
"homepage": "https://adobe.github.io/spectrum-web-components/components/rule", | ||
"keywords": [ | ||
"spectrum css", | ||
"web components", | ||
"lit-element", | ||
"lit-html" | ||
], | ||
"version": "0.0.1", | ||
"description": "", | ||
"main": "lib/index.js", | ||
"module": "lib/index.js", | ||
"type": "module", | ||
"files": [ | ||
"custom-elements.json", | ||
"/lib/", | ||
"/src/" | ||
], | ||
"scripts": { | ||
"test": "karma start --coverage" | ||
}, | ||
"author": "", | ||
"license": "Apache-2.0", | ||
"peerDependencies": { | ||
"lit-element": "^2.1.0", | ||
"lit-html": "^1.0.0" | ||
}, | ||
"devDependencies": { | ||
"@spectrum-css/rule": "^2.0.0" | ||
}, | ||
"dependencies": { | ||
"tslib": "^1.10.0" | ||
} | ||
} |
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,26 @@ | ||
/* | ||
Copyright 2020 Adobe. All rights reserved. | ||
This file is licensed to you under the Apache License, Version 2.0 (the "License"); | ||
you may not use this file except in compliance with the License. You may obtain a copy | ||
of the License at http://www.apache.org/licenses/LICENSE-2.0 | ||
Unless required by applicable law or agreed to in writing, software distributed under | ||
the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS | ||
OF ANY KIND, either express or implied. See the License for the specific language | ||
governing permissions and limitations under the License. | ||
*/ | ||
|
||
export * from './rule.js'; | ||
|
||
import { Rule } from './rule.js'; | ||
|
||
/* istanbul ignore else */ | ||
if (!customElements.get('sp-rule')) { | ||
customElements.define('sp-rule', Rule); | ||
} | ||
|
||
declare global { | ||
interface HTMLElementTagNameMap { | ||
'sp-rule': Rule; | ||
} | ||
} |
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 @@ | ||
/* | ||
Copyright 2020 Adobe. All rights reserved. | ||
This file is licensed to you under the Apache License, Version 2.0 (the "License"); | ||
you may not use this file except in compliance with the License. You may obtain a copy | ||
of the License at http://www.apache.org/licenses/LICENSE-2.0 | ||
Unless required by applicable law or agreed to in writing, software distributed under | ||
the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS | ||
OF ANY KIND, either express or implied. See the License for the specific language | ||
governing permissions and limitations under the License. | ||
*/ | ||
|
||
@import './spectrum-rule.css'; | ||
|
||
:host { | ||
display: block; | ||
} | ||
|
||
hr { | ||
border: none; | ||
margin: 0; | ||
} |
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,38 @@ | ||
/* | ||
Copyright 2020 Adobe. All rights reserved. | ||
This file is licensed to you under the Apache License, Version 2.0 (the "License"); | ||
you may not use this file except in compliance with the License. You may obtain a copy | ||
of the License at http://www.apache.org/licenses/LICENSE-2.0 | ||
Unless required by applicable law or agreed to in writing, software distributed under | ||
the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS | ||
OF ANY KIND, either express or implied. See the License for the specific language | ||
governing permissions and limitations under the License. | ||
*/ | ||
|
||
import { | ||
html, | ||
LitElement, | ||
CSSResultArray, | ||
TemplateResult, | ||
property, | ||
} from 'lit-element'; | ||
|
||
import styles from './rule.css'; | ||
|
||
/** | ||
* @element sp-rule | ||
*/ | ||
export class Rule extends LitElement { | ||
public static styles: CSSResultArray = [styles]; | ||
|
||
@property({ type: Boolean, reflect: true }) | ||
public vertical = false; | ||
|
||
protected render(): TemplateResult { | ||
if (this.vertical) return html``; | ||
return html` | ||
<hr /> | ||
`; | ||
} | ||
} |
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 @@ | ||
/* | ||
Copyright 2020 Adobe. All rights reserved. | ||
This file is licensed to you under the Apache License, Version 2.0 (the "License"); | ||
you may not use this file except in compliance with the License. You may obtain a copy | ||
of the License at http://www.apache.org/licenses/LICENSE-2.0 | ||
Unless required by applicable law or agreed to in writing, software distributed under | ||
the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS | ||
OF ANY KIND, either express or implied. See the License for the specific language | ||
governing permissions and limitations under the License. | ||
*/ | ||
|
||
module.exports = { | ||
spectrum: 'rule', | ||
components: [ | ||
{ | ||
name: 'rule', | ||
host: { | ||
selector: '.spectrum-Rule', | ||
}, | ||
attributes: [ | ||
{ | ||
selector: '.spectrum-Rule--vertical', | ||
type: 'boolean', | ||
name: 'vertical', | ||
}, | ||
{ | ||
type: 'enum', | ||
name: 'size', | ||
values: [ | ||
'.spectrum-Rule--small', | ||
'.spectrum-Rule--medium', | ||
'.spectrum-Rule--large', | ||
], | ||
}, | ||
], | ||
}, | ||
], | ||
}; |
Oops, something went wrong.