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

feat(breadcrumb): add the breadcrumb component #1260

Merged
merged 30 commits into from
May 8, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
30 commits
Select commit Hold shift + click to select a range
289dc68
Add breadcrumb from vivid-3
YonatanKra Mar 18, 2022
e6842c1
Snapshots for breadcrumb
YonatanKra Mar 18, 2022
81277aa
Update breadcrumb docs
YonatanKra Mar 18, 2022
8d5d335
Update example
YonatanKra Mar 18, 2022
0b71dcc
Remove unneeded deps
YonatanKra Mar 19, 2022
1a31561
Update components/breadcrumb/package.json
YonatanKra Mar 19, 2022
3d0443e
add required imports
yinonov Mar 19, 2022
9b6598b
Fix the expansion panel build
YonatanKra Mar 31, 2022
2771fb8
Merge remote-tracking branch 'upstream/master' into breadcrumb-component
YonatanKra Mar 31, 2022
a2b3907
Proxy icon
YonatanKra Apr 2, 2022
003f571
Tests now complete fully
YonatanKra Apr 2, 2022
aa181fd
Update snapshots
YonatanKra Apr 2, 2022
faa1c52
Update versions
YonatanKra May 2, 2022
a825bdd
Merge remote-tracking branch 'upstream/master' into breadcrumb-component
YonatanKra May 2, 2022
b597cf2
Fix the style
YonatanKra May 2, 2022
1d9e0e7
Update badge template
YonatanKra May 2, 2022
a821e5c
Update storybook
YonatanKra May 2, 2022
992ddaa
Fix linting
YonatanKra May 2, 2022
ca451c3
Revert icon related changes
YonatanKra May 2, 2022
b1e09c6
Update components/breadcrumb/package.json
YonatanKra May 2, 2022
71381db
Revert vonage/vivid version
YonatanKra May 2, 2022
ea3c2c1
Update breadcrumb
YonatanKra May 6, 2022
b3e6f02
Update version
YonatanKra May 6, 2022
c89aacd
Remove dep
YonatanKra May 6, 2022
ef392fb
Remove another dep
YonatanKra May 6, 2022
1799f96
Merge branch 'master' into breadcrumb-component
YonatanKra May 6, 2022
b89950d
hard code breadcrumbs
YonatanKra May 8, 2022
fdbc95a
Stylelint
YonatanKra May 8, 2022
db80c21
linting
YonatanKra May 8, 2022
cb6df73
Design feedback
YonatanKra May 8, 2022
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
16 changes: 16 additions & 0 deletions __snapshots__/Breadcrumb-item.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
# `Breadcrumb-item`

#### `should internal contents`

```html
<div
class="breadcrumb-item control"
part="listitem"
roll="listitem"
>
<vwc-icon type="chevron-right-line">
</vwc-icon>
</div>

```

16 changes: 16 additions & 0 deletions __snapshots__/Breadcrumb.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
# `Breadcrumb`

#### `should internal contents`

```html
<div
class="list"
part="list"
role="list"
>
<slot>
</slot>
</div>

```

6 changes: 6 additions & 0 deletions __snapshots__/snackbar.md
Original file line number Diff line number Diff line change
Expand Up @@ -156,6 +156,7 @@
</div>
YonatanKra marked this conversation as resolved.
Show resolved Hide resolved
</div>
</div>

```

#### `should have internal contents (header) - flavor = 'legacy'`
Expand All @@ -180,6 +181,7 @@
</div>
</div>
</div>

```

#### `should have internal contents (message) - flavor = 'legacy'`
Expand All @@ -198,6 +200,7 @@
</div>
</div>
</div>

```

#### `should have internal contents (icon) - flavor = 'legacy'`
Expand All @@ -221,6 +224,7 @@
</div>
</div>
</div>

```

#### `should have internal contents (dismissible) - flavor = 'legacy'`
Expand Down Expand Up @@ -248,6 +252,7 @@
</div>
</div>
</div>

```

#### `should have internal contents (slotted action) - flavor = 'legacy'`
Expand All @@ -266,5 +271,6 @@
</div>
</div>
</div>

```

10 changes: 6 additions & 4 deletions common/umbrella/tools/style-modules/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,20 +10,22 @@ const

const DEFAULT_PATH = "./src/**/";
const DEFAULT_SOURCE = "*.s[ac]ss";
const DEFAULT_CSS_LIB = 'lit-element';

const {
path: basePath = DEFAULT_PATH,
source: sourcePattern = DEFAULT_SOURCE
source: sourcePattern = DEFAULT_SOURCE,
cssLib: cssLib = DEFAULT_CSS_LIB
} = parseArgs(process.argv.slice(2));

console.time('Total');

const
fileStreamFromGlob = (path)=> kefir.fromNodeCallback(fp.partial(glob, [path])).flatten(),
tsTemplate = (css)=> [
"// autogenerated module",
"import {css} from 'lit-element';",
["export const style = css`", css, "`;"].join('')
'// autogenerated module',
`import {css} from '${cssLib}';`,
['export const style = css`', css, '`;'].join('')
].join('\n'),
prefixWith = (path)=> (pre)=> joinPath(...[getDir(path), [pre, getBase(path)].join('')]),
suffixWith = (path)=> (suf)=> joinPath(...[getDir(path), [getBase(path), suf].filter(Boolean).join('.')]);
Expand Down
38 changes: 38 additions & 0 deletions components/breadcrumb-item/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
{
"name": "@vonage/vwc-breadcrumb-item",
"version": "2.28.2",
"description": "breadcrumb-item component",
"homepage": "https://github.com/Vonage/vivid/tree/master/components/breadcrumb-item#readme",
"license": "ISC",
"main": "vwc-breadcrumb-item.js",
"module": "vwc-breadcrumb-item.js",
"files": [
"*.js",
"*.ts",
"*.map"
],
"repository": {
"type": "git",
"url": "https://github.com/vonage/vivid.git",
"directory": "components/breadcrumb-item"
},
"scripts": {
"build:typescript": "tsc -b",
"build:styles": "umbrella-style-modules --cssLib '@microsoft/fast-element'",
Copy link
Contributor

Choose a reason for hiding this comment

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

ok got it

"build": "yarn run build:styles && yarn run build:typescript"
},
"bugs": {
"url": "https://github.com/Vonage/vivid/issues"
},
"dependencies": {
"@microsoft/fast-element": "^1.10.1",
"@microsoft/fast-foundation": "^2.46.2",
"tslib": "^2.3.0"
},
"devDependencies": {
"@vonage/vvd-design-tokens": "2.29.0",
"@vonage/vvd-typography": "2.29.0",
"@vonage/vvd-umbrella": "2.29.0",
"typescript": "^4.3.2"
}
}
15 changes: 15 additions & 0 deletions components/breadcrumb-item/readme.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
# vwc-breadcrumb-item

Add a description of vwc-breadcrumb-item.

## Properties

| Property | Type |
|---------------------------|-------------------------------------------|
| `prop ` | `propType` |

## Methods

| Method | Type |
|---------|------------|
| `method`| `(): void` |
49 changes: 49 additions & 0 deletions components/breadcrumb-item/src/text-anchor.template.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
import { html } from '@microsoft/fast-element';
import type { ViewTemplate } from '@microsoft/fast-element';
import type {
ElementDefinitionContext,
FoundationElementDefinition,
} from '@microsoft/fast-foundation';
import { classNames } from '@microsoft/fast-web-utilities';

const getClasses = () => classNames(
'control',
);

export const textAnchorTemplate: (
context: ElementDefinitionContext,
definition: FoundationElementDefinition
) => ViewTemplate<any> = () => html`<a
class="${getClasses}"
download="${x => x.download}"
href="${x => x.href}"
hreflang="${x => x.hreflang}"
ping="${x => x.ping}"
referrerpolicy="${x => x.referrerpolicy}"
rel="${x => x.rel}"
target="${x => x.target}"
type="${x => x.type}"
aria-atomic="${x => x.ariaAtomic}"
aria-busy="${x => x.ariaBusy}"
aria-controls="${x => x.ariaControls}"
aria-current="${x => x.ariaCurrent}"
aria-describedby="${x => x.ariaDescribedby}"
aria-details="${x => x.ariaDetails}"
aria-disabled="${x => x.ariaDisabled}"
aria-errormessage="${x => x.ariaErrormessage}"
aria-expanded="${x => x.ariaExpanded}"
aria-flowto="${x => x.ariaFlowto}"
aria-haspopup="${x => x.ariaHaspopup}"
aria-hidden="${x => x.ariaHidden}"
aria-invalid="${x => x.ariaInvalid}"
aria-keyshortcuts="${x => x.ariaKeyshortcuts}"
aria-label="${x => x.ariaLabel}"
aria-labelledby="${x => x.ariaLabelledby}"
aria-live="${x => x.ariaLive}"
aria-owns="${x => x.ariaOwns}"
aria-relevant="${x => x.ariaRelevant}"
aria-roledescription="${x => x.ariaRoledescription}"
>
${x => x.text}
</a>
`;
27 changes: 27 additions & 0 deletions components/breadcrumb-item/src/vwc-breadcrumb-item.scss
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
@use '@vonage/vvd-typography/scss/typography' as typography;
@use '@vonage/vvd-design-tokens/build/scss/semantic-variables/scheme-variables' as theme-consts;

.breadcrumb-item {
--icon-size: 12px;
@include typography.typography-cat-shorthand('body-2');

display: flex;
align-items: center;
color: var(#{theme-consts.$vvd-color-on-canvas});

a {
color: var(--vvd-color-cta-70);
font: inherit;
text-decoration: none;
}

a:hover {
text-decoration: underline;
}

vwc-icon {
margin: 0 16px;
color: var(#{theme-consts.$vvd-color-neutral-70});
font-size: 12px;
}
}
37 changes: 37 additions & 0 deletions components/breadcrumb-item/src/vwc-breadcrumb-item.template.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
import {html, when} from '@microsoft/fast-element';
import type { ViewTemplate } from '@microsoft/fast-element';
import type {
ElementDefinitionContext,
FoundationElementDefinition,
} from '@microsoft/fast-foundation';
import { classNames } from '@microsoft/fast-web-utilities';
import {textAnchorTemplate} from './text-anchor.template.js';
import type { BreadcrumbItem } from './vwc-breadcrumb-item.js';

const getClasses = (_: BreadcrumbItem) =>
classNames(
'control', 'breadcrumb-item'
);

/**
* The template for the {@link @microsoft/fast-foundation#BreadcrumbItem} component.
*
* @param context
* @param definition
* @public
*/
export const BreadcrumbItemTemplate: (
context: ElementDefinitionContext,
definition: FoundationElementDefinition
) => ViewTemplate<BreadcrumbItem> =
(context: ElementDefinitionContext, definition: FoundationElementDefinition) => html`
<div roll="listitem" part="listitem" class="${getClasses}">
${when(x => x.text && !x.href,
html<BreadcrumbItem>`${x => x.text}`)}

${when(x => x.text && x.href && x.href.length > 0,
html<BreadcrumbItem>`${textAnchorTemplate(context, definition)}`)}

${when(x => x.separator,
html<BreadcrumbItem>`<vwc-icon type="chevron-right-solid"></vwc-icon>`)}
</div>`;
27 changes: 27 additions & 0 deletions components/breadcrumb-item/src/vwc-breadcrumb-item.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@

import type { FoundationElementDefinition } from '@microsoft/fast-foundation';
import { DesignSystem, BreadcrumbItem as FastBreadcrumbItem } from '@microsoft/fast-foundation';
import { attr } from '@microsoft/fast-element';
import {BreadcrumbItemTemplate as template} from './vwc-breadcrumb-item.template.js';
import { style as styles } from './vwc-breadcrumb-item.css.js';

/**
* Base class for breadcrumb-item
*
* @public
*/
export class BreadcrumbItem extends FastBreadcrumbItem {
@attr text?: string;

constructor() {
super();
}
}

export const vividBreadcrumbItem = BreadcrumbItem.compose<FoundationElementDefinition>({
baseName: 'breadcrumb-item',
template: template as any,
styles,
});

DesignSystem.getOrCreate().withPrefix('vwc').register(vividBreadcrumbItem());
21 changes: 21 additions & 0 deletions components/breadcrumb-item/test/breadcrumb-item.test.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
import '../vwc-breadcrumb-item.js';
import {
waitNextTask,
textToDomToParent,
isolatedElementsCreation
} from '../../../test/test-helpers.js';
import { chaiDomDiff } from '@open-wc/semantic-dom-diff';

chai.use(chaiDomDiff);

const COMPONENT_NAME = 'vwc-breadcrumb-item';

describe('Breadcrumb-item', () => {
let addElement = isolatedElementsCreation();

it(`${COMPONENT_NAME} is defined as a custom element`, async () => {
assert.exists(
customElements.get(COMPONENT_NAME)
);
});
});
16 changes: 16 additions & 0 deletions components/breadcrumb-item/tsconfig.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
{
"extends": "@vonage/vvd-umbrella/configs/tsconfig.json",
"compilerOptions": {
"module": "ESNext",
"composite": true,
"rootDir": "src",
"outDir": ".",
"tsBuildInfoFile": ".tsbuildinfo"
},
"include": [
"src/*.ts"
],
"exclude": [
"src/test/*.ts"
]
}
38 changes: 38 additions & 0 deletions components/breadcrumb/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
{
"name": "@vonage/vwc-breadcrumb",
"version": "2.28.2",
"description": "breadcrumb component",
"homepage": "https://github.com/Vonage/vivid/tree/master/components/breadcrumb#readme",
"license": "ISC",
"main": "vwc-breadcrumb.js",
"module": "vwc-breadcrumb.js",
"files": [
"*.js",
"*.ts",
"*.map"
],
"repository": {
"type": "git",
"url": "https://github.com/vonage/vivid.git",
"directory": "components/breadcrumb"
},
"scripts": {
"build:typescript": "tsc -b",
"build:styles": "umbrella-style-modules",
"build": "yarn run build:styles && yarn run build:typescript"
},
"bugs": {
"url": "https://github.com/Vonage/vivid/issues"
},
"dependencies": {
"@microsoft/fast-element": "^1.10.1",
"@microsoft/fast-foundation": "^2.46.2",
"@vonage/vvd-core": "2.29.0",
"@vonage/vwc-icon": "2.29.0",
"tslib": "^2.3.0"
},
"devDependencies": {
"@vonage/vvd-umbrella": "2.29.0",
"typescript": "^4.3.2"
}
}