Skip to content

Commit

Permalink
Add visually hidden package
Browse files Browse the repository at this point in the history
  • Loading branch information
bjarnef committed Oct 3, 2023
1 parent 6575986 commit 41b2e58
Show file tree
Hide file tree
Showing 10 changed files with 183 additions and 0 deletions.
11 changes: 11 additions & 0 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

31 changes: 31 additions & 0 deletions packages/uui-visually-hidden/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
# uui-visually-hidden

![npm](https://img.shields.io/npm/v/@umbraco-ui/uui-visually-hidden?logoColor=%231B264F)

Umbraco style visually-hidden component.

## Installation

### ES imports

```zsh
npm i @umbraco-ui/uui-visually-hidden
```

Import the registration of `<uui-visually-hidden>` via:

```javascript
import '@umbraco-ui/uui-visually-hidden';
```

When looking to leverage the `UUIVisuallyHiddenElement` base class as a type and/or for extension purposes, do so via:

```javascript
import { UUIVisuallyHiddenElement } from '@umbraco-ui/uui-visually-hidden';
```

## Usage

```html
<uui-visually-hidden></uui-visually-hidden>
```
1 change: 1 addition & 0 deletions packages/uui-visually-hidden/lib/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export * from './uui-visually-hidden.element';
28 changes: 28 additions & 0 deletions packages/uui-visually-hidden/lib/uui-visually-hidden.element.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
import { defineElement } from '@umbraco-ui/uui-base/lib/registration';
import { css, html, LitElement } from 'lit';

/**
* @element uui-visually-hidden
*/
@defineElement('uui-visually-hidden')
export class UUIVisuallyHiddenElement extends LitElement {
static styles = [
css`
:host {
/* Styles goes here */
}
`,
];

render(){
return html`
Markup goes here
`;
}
}

declare global {
interface HTMLElementTagNameMap {
'uui-visually-hidden': UUIVisuallyHiddenElement ;
}
}
24 changes: 24 additions & 0 deletions packages/uui-visually-hidden/lib/uui-visually-hidden.story.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
import type { Meta, StoryObj } from '@storybook/web-components';

import './uui-visually-hidden.element';
import type { UUIVisuallyHiddenElement } from './uui-visually-hidden.element';
import readme from '../README.md?raw';

const meta: Meta<UUIVisuallyHiddenElement> = {
id: 'uui-visually-hidden',
title: 'Visually Hidden',
component: 'uui-visually-hidden',
parameters: {
readme: { markdown: readme },
docs: {
source: {
code: `<uui-visually-hidden></uui-visually-hidden>`,
},
},
},
};

export default meta;
type Story = StoryObj<UUIVisuallyHiddenElement>;

export const Overview: Story = {};
20 changes: 20 additions & 0 deletions packages/uui-visually-hidden/lib/uui-visually-hidden.test.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
import { html, fixture, expect } from '@open-wc/testing';
import { UUIVisuallyHiddenElement } from './uui-visually-hidden.element';

describe('UUIVisuallyHiddenElement', () => {
let element: UUIVisuallyHiddenElement;

beforeEach(async () => {
element = await fixture(
html` <uui-visually-hidden></uui-visually-hidden> `
);
});

it('is defined with its own instance', () => {
expect(element).to.be.instanceOf(UUIVisuallyHiddenElement);
});

it('passes the a11y audit', async () => {
await expect(element).shadowDom.to.be.accessible();
});
});
44 changes: 44 additions & 0 deletions packages/uui-visually-hidden/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
{
"name": "@umbraco-ui/uui-visually-hidden",
"version": "0.0.0",
"license": "MIT",
"keywords": [
"Umbraco",
"Custom elements",
"Web components",
"UI",
"Lit",
"Visually Hidden"
],
"description": "Umbraco UI visually-hidden component",
"repository": {
"type": "git",
"url": "https://github.com/umbraco/Umbraco.UI.git",
"directory": "packages/uui-visually-hidden"
},
"bugs": {
"url": "https://github.com/umbraco/Umbraco.UI/issues"
},
"main": "./lib/index.js",
"module": "./lib/index.js",
"types": "./lib/index.d.ts",
"type": "module",
"customElements": "custom-elements.json",
"files": [
"lib/**/*.d.ts",
"lib/**/*.js",
"custom-elements.json"
],
"dependencies": {
"@umbraco-ui/uui-base": "1.5.0-rc.0"
},
"scripts": {
"build": "npm run analyze && tsc --build --force && rollup -c rollup.config.js",
"clean": "tsc --build --clean && rimraf -g dist lib/*.js lib/**/*.js *.tgz lib/**/*.d.ts custom-elements.json",
"analyze": "web-component-analyzer **/*.element.ts --outFile custom-elements.json"
},
"publishConfig": {
"access": "public"
},
"homepage": "https://uui.umbraco.com/?path=/story/uui-visually-hidden"
}
5 changes: 5 additions & 0 deletions packages/uui-visually-hidden/rollup.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
import { UUIProdConfig } from '../rollup-package.config.mjs';

export default UUIProdConfig({
entryPoints: ['index']
});
17 changes: 17 additions & 0 deletions packages/uui-visually-hidden/tsconfig.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
// Don't edit this file directly. It is generated by /scripts/generate-ts-config.js

{
"extends": "../../tsconfig.json",
"compilerOptions": {
"outDir": "./lib",
"rootDir": "./lib",
"composite": true
},
"include": ["./**/*.ts"],
"exclude": ["./**/*.test.ts", "./**/*.story.ts"],
"references": [
{
"path": "../uui-base"
}
]
}
2 changes: 2 additions & 0 deletions packages/uui/lib/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -78,3 +78,5 @@ export * from '@umbraco-ui/uui-toast-notification-container/lib';
export * from '@umbraco-ui/uui-toast-notification-layout/lib';
export * from '@umbraco-ui/uui-toast-notification/lib';
export * from '@umbraco-ui/uui-toggle/lib';

export * from '@umbraco-ui/uui-visually-hidden/lib/index.js';

0 comments on commit 41b2e58

Please sign in to comment.