Skip to content

Commit

Permalink
Merge branch 'master' into westbrook/225/search
Browse files Browse the repository at this point in the history
  • Loading branch information
Westbrook Johnson authored Oct 10, 2019
2 parents 8c4fe78 + 46e1bdd commit 46d8eda
Show file tree
Hide file tree
Showing 33 changed files with 894 additions and 48 deletions.
8 changes: 4 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ It will not support older browsers and will only target modern ever-green browse

# Requirements

- NodeJS >= 8.10.0
- NodeJS >= 10.15
- Typescript
- Browsers with Custom Elements V1 and Shadow DOM support, e.g. Chrome, Firefox, Safari.

Expand Down Expand Up @@ -42,7 +42,7 @@ By default the resulting site will be available at [http://localhost:6006](http:

## Linting

The project will be linted on a pre-commit hook, but you can also run the lint suite with `npm run lint`. It uses ESLint to lint the JS / TS files, and StyleLint to lint the CSS files.
The project will be linted on a pre-commit hook, but you can also run the lint suite with `yarn lint`. It uses ESLint to lint the JS / TS files, and StyleLint to lint the CSS files.

## Testing

Expand All @@ -52,7 +52,7 @@ Tests are implemented using the Karma test runner with Chai, Mocha and Sinon fra
yarn test
```

During development you may wish to use `npm run test:watch` to automatically build and re-run the test suites.
During development you may wish to use `yarn test:watch` to automatically build and re-run the test suites.

## Benchmarking

Expand All @@ -63,7 +63,7 @@ yarn build:tests
yarn test:bench
```

This will run the defined [Tachometer](https://www.npmjs.com/package/tachometer) tests and report the current runtime cost of each individual element. When not making changes to the benchmarks thy have been built on your local machine, you can stip `npm run build:tests` for later passes.
This will run the defined [Tachometer](https://www.npmjs.com/package/tachometer) tests and report the current runtime cost of each individual element. When not making changes to the benchmarks thy have been built on your local machine, you can stip `yarn build:tests` for later passes.

## Anatomy of a Component

Expand Down
19 changes: 19 additions & 0 deletions __snapshots__/Actionbar.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
# `Actionbar`

#### `loads`

```html
<sp-checkbox indeterminate="" tabindex="0">
228 Selected
</sp-checkbox>
<div class="spectrum-ButtonGroup">
<sp-action-button quiet="" tabindex="0"></sp-action-button>
<sp-action-button quiet="" tabindex="0"></sp-action-button>
</div>
```

```html
<sp-popover direction="none" id="popover" open="">
<slot></slot>
</sp-popover>
```
2 changes: 0 additions & 2 deletions __snapshots__/Slider.md
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,6 @@
max="20"
min="0"
step="1"
tabindex="0"
type="range"
value="10"
/>
Expand Down Expand Up @@ -63,7 +62,6 @@
max="20"
min="0"
step="1"
tabindex="0"
type="range"
value="10"
/>
Expand Down
8 changes: 6 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -33,10 +33,12 @@
"process-spectrum": "node ./scripts/process-spectrum-css.js; npx pretty-quick --pattern 'packages/**/*.css'",
"process-icons": "node ./scripts/process-icons.js; npx pretty-quick --pattern 'packages/**/*.svg.ts'",
"build": "gulp css && tsc --build packages/**/tsconfig.json",
"build:watch": "tsc --build packages/**/tsconfig.json -w",
"build:tests": "tsc --build test/tsconfig.json && tsc --build test/tsconfig-node.json",
"build:clear-cache": "rm -rf packages/*/lib && rm -rf packages/*/tsconfig.tsbuildinfo",
"watch": "gulp watch",
"storybook": "yarn watch & tsc --build packages/**/tsconfig.json -w & start-storybook -p 6006",
"storybook": "run-p watch build:watch storybook:start",
"storybook:start": "start-storybook -p 6006",
"storybook:build": "build-storybook -c .storybook -o ./documentation/dist/storybook",
"docs:build": "gulp docsCompile && yarn storybook:build",
"docs:start": "gulp docsWatchCompile",
Expand All @@ -48,7 +50,8 @@
"lerna-publish": "lerna publish --message 'chore: release new versions'",
"test": "yarn test:build && karma start --coverage",
"test:build": "yarn build && tsc --build test/tsconfig-test.json",
"test:watch": "yarn watch & yarn test:build -- -w & karma start --auto-watch=true --single-run=false",
"test:start": "karma start",
"test:watch": "run-p watch 'test:build -w' 'test:start --auto-watch=true --single-run=false'",
"test:update-snapshots": "yarn test:build && karma start --update-snapshots",
"test:prune-snapshots": "yarn test:build && karma start --prune-snapshots",
"test:compatibility": "yarn test:build && karma start --compatibility all --auto-watch=true --single-run=false",
Expand Down Expand Up @@ -141,6 +144,7 @@
"markdown-loader": "^5.1.0",
"marked": "^0.7.0",
"merge2": "^1.2.3",
"npm-run-all": "^4.1.5",
"plugin-error": "^1.0.1",
"polymer-webpack-loader": "^2.0.3",
"postcss": "^7.0.6",
Expand Down
1 change: 1 addition & 0 deletions packages/action-menu/src/action-menu.ts
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,7 @@ export class ActionMenu extends Dropdown {
}

protected firstUpdated(): void {
super.firstUpdated();
this.quiet = true;
}
}
72 changes: 72 additions & 0 deletions packages/actionbar/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@
## Overview

A `<sp-actionbar>` delivers a floating action bar that is a convenient way to deliver stateful actions in cases like selection mode. `<sp-actionbar>` can be deployed in two variants beyond the default: `[varient="fixed"]`, to position the element in relation to the page, and `[variant=sticky]`, to position the content in relation to content that may scroll.

## Example

```html
<sp-actionbar open>
<sp-checkbox indeterminate>228 Selected</sp-checkbox>
<div class="spectrum-ButtonGroup">
<sp-action-button quiet>
<svg slot="icon" id="spectrum-icon-18-Edit" viewBox="0 0 36 36">
<path
d="M33.567 8.2L27.8 2.432a1.215 1.215 0 0 0-.866-.353H26.9a1.371 1.371 0 0 0-.927.406L5.084 23.372a.99.99 0 0 0-.251.422L2.055 33.1c-.114.377.459.851.783.851a.251.251 0 0 0 .062-.007c.276-.063 7.866-2.344 9.311-2.778a.972.972 0 0 0 .414-.249l20.888-20.889a1.372 1.372 0 0 0 .4-.883 1.221 1.221 0 0 0-.346-.945zM11.4 29.316c-2.161.649-4.862 1.465-6.729 2.022l2.009-6.73z"
></path>
</svg>
</sp-action-button>
<sp-action-button quiet>
<svg slot="icon" id="spectrum-icon-18-More" viewBox="0 0 36 36">
<circle cx="17.8" cy="18.2" r="3.4"></circle>
<circle cx="29.5" cy="18.2" r="3.4"></circle>
<circle cx="6.1" cy="18.2" r="3.4"></circle>
</svg>
</sp-action-button>
</div>
</sp-actionbar>
```

## Variants

### Fixed

When using `[variant="fixed"]`, the `<sp-actionbar>` will display by default at the bottom left of the window and can be customized via CSS from the outside.

```html
<h4>Look down and to the left when toggling.</h4>
<sp-actionbar variant="fixed">
<sp-checkbox indeterminate>228 Selected</sp-checkbox>
</sp-actionbar>
<sp-button
onclick="javascript:this.previousElementSibling.open = !this.previousElementSibling.open;"
>
Toggle Fixed Actionbar
</sp-button>
```

### Sticky

When using `[variant="sticky"]`, be sure you've spent some time touching up on [how `sticky` really works](https://medium.com/@elad/css-position-sticky-how-it-really-works-54cd01dc2d46) to ensure the most successful delivery of your content.

```html
<section style="position: relative; max-height: 6em; overflow: auto;">
<h4>Scroll down for toggle button</h4>
<sp-actionbar variant="sticky" style="top: 0;">
<sp-checkbox indeterminate>228 Selected</sp-checkbox>
</sp-actionbar>
<p>
Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod
tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim
veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea
commodo consequat. Duis aute irure dolor in reprehenderit in voluptate
velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint
occaecat cupidatat non proident, sunt in culpa qui officia deserunt
mollit anim id est laborum.
</p>
<sp-button
onclick="javascript:this.previousElementSibling.previousElementSibling.open = !this.previousElementSibling.previousElementSibling.open;"
>
Toggle Sticky Actionbar
</sp-button>
</section>
```
41 changes: 41 additions & 0 deletions packages/actionbar/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
{
"name": "@spectrum-web-components/actionbar",
"publishConfig": {
"access": "public"
},
"repository": {
"type": "git",
"url": "https://github.com/adobe/spectrum-web-components.git",
"directory": "packages/actionbar"
},
"bugs": {
"url": "https://github.com/adobe/spectrum-web-components/issues"
},
"homepage": "https://adobe.github.io/spectrum-web-components/components/actionbar",
"keywords": [
"spectrum css",
"web components",
"lit-element",
"lit-html"
],
"version": "0.0.1",
"description": "",
"main": "lib/index.js",
"module": "lib/index.js",
"files": [
"/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/actionbar": "^2.0.0-alpha.6"
}
}
17 changes: 17 additions & 0 deletions packages/actionbar/src/actionbar.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
/*
Copyright 2019 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-actionbar.css';

:host([grows]) #popover {
width: auto;
}
69 changes: 69 additions & 0 deletions packages/actionbar/src/actionbar.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
/*
Copyright 2019 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 actionbarStyles from './actionbar.css.js';

export const actionbarVariants = ['sticky', 'fixed'];

/**
* Actionbar component
*/
export class Actionbar extends LitElement {
public static get styles(): CSSResultArray {
return [actionbarStyles];
}

@property({ type: Boolean, reflect: true })
public open = false;

/**
* The variant applies specific styling when set to `sticky` or `fixed`.
* `variant` attribute is removed when not matching one of the above.
*
* @param {String} variant
*/
@property({ type: String, reflect: true })
public set variant(variant: string) {
if (variant === this.variant) {
return;
}
if (actionbarVariants.includes(variant)) {
this.setAttribute('variant', variant);
this._variant = variant;
return;
}
this.removeAttribute('variant');
this._variant = '';
}

public get variant(): string {
return this._variant;
}

private _variant = '';

public render(): TemplateResult {
return html`
<sp-popover open id="popover">
<slot></slot>
</sp-popover>
`;
}
}
25 changes: 25 additions & 0 deletions packages/actionbar/src/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
/*
Copyright 2019 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 './actionbar.js';

import { Actionbar } from './actionbar.js';

/* istanbul ignore else */
if (!customElements.get('sp-actionbar')) {
customElements.define('sp-actionbar', Actionbar);
}

declare global {
interface HTMLElementTagNameMap {
'sp-actionbar': Actionbar;
}
}
Loading

0 comments on commit 46d8eda

Please sign in to comment.