Skip to content

Commit

Permalink
refactor: scope element (#3)
Browse files Browse the repository at this point in the history
* refactor: scope scl text field

* ci: update screenshots

* docs: readme

* test: remove failed screenshots

* ci: update screenshots

* test: some more shit at the wall throwing

* test: some more shit at the wall throwing

* test: some more dump stuff

* ci: update screenshots

* test: some more dump stuff

* ci: update screenshots

* test: some more tests

* ci: update screenshots

* test: storybook polyfill loading

* ci: update screenshots

* test: improve pipeline

* chore: remove vulnarablities

---------

Co-authored-by: JakobVogelsang <[email protected]>
  • Loading branch information
JakobVogelsang and JakobVogelsang authored Dec 29, 2024
1 parent 34a3c92 commit 1558f51
Show file tree
Hide file tree
Showing 29 changed files with 8,633 additions and 23,542 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/test-on-pr-branch.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ jobs:
- name: Set up Node.js
uses: actions/setup-node@v3
with:
node-version: '16'
node-version: '20'

- name: Install dependencies
run: npm ci
Expand All @@ -20,4 +20,4 @@ jobs:
run: npx playwright install --with-deps

- name: Run tests
run: npm run-script test
run: npm run test
41 changes: 6 additions & 35 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
@@ -1,27 +1,9 @@
name: Test
on: push

jobs:
unit:
runs-on: ubuntu-20.04
steps:
- name: Checkout
uses: actions/checkout@v3
on: workflow_dispatch

- name: Set up Node.js
uses: actions/setup-node@v3
with:
node-version: '16'

- name: Install dependencies
run: npm ci

- name: Install playwright browsers
run: npx playwright install --with-deps

- name: Run unit tests
run: npm run-script test:unit
visual:
jobs:
test:
runs-on: ubuntu-20.04
steps:
- name: Checkout
Expand All @@ -30,24 +12,13 @@ jobs:
- name: Set up Node.js
uses: actions/setup-node@v3
with:
node-version: '16'
node-version: '20'

- name: Install dependencies
run: npm ci

- name: Install playwright browsers
run: npx playwright install --with-deps

- name: Run visual test
run: npm run-script test:visual

- name: Update screenshots
if: failure()
run: npm run test:update

- name: Commit changes
if: failure()
uses: EndBug/add-and-commit@v9
with:
message: 'ci: update screenshots'
add: 'screenshots'
- name: Run tests
run: npm run test
7 changes: 6 additions & 1 deletion .storybook/server.mjs
Original file line number Diff line number Diff line change
@@ -1,8 +1,13 @@
import { storybookPlugin } from '@web/dev-server-storybook';
import baseConfig from '../web-dev-server.config.mjs';
import { polyfill } from '@web/dev-server-polyfill';


export default /** @type {import('@web/dev-server').DevServerConfig} */ ({
...baseConfig,
open: '/',
plugins: [storybookPlugin({ type: 'web-components' }), ...baseConfig.plugins],
plugins: [
polyfill({
scopedCustomElementRegistry: true,
}),storybookPlugin({ type: 'web-components' }), ...baseConfig.plugins],
});
79 changes: 53 additions & 26 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,38 +7,57 @@ This is a web component meant to be used for SCL type attributes. In addition to
This element was meant to be used only for plugins in this organization. If it still fills you bill please use or re-use it. But be aware that we will not react on features wishes that do not contribute to the needs of plugin in this organization.


## `scl-text-field.ts`:
## `SclTextField.ts`:

### class: `SclTextField`
### class: `SclTextField`, `scl-text-field`

#### Superclass

| Name | Module | Package |
| ------------ | ------ | ------- |
| `LitElement` | | lit |

#### Mixins

| Name | Module | Package |
| --------------------- | ------ | --------------------------------------- |
| `ScopedElementsMixin` | | @open-wc/scoped-elements/lit-element.js |

#### Static Fields

| Name | Privacy | Type | Default | Description | Inherited From |
| ---------------- | ------- | -------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ----------- | -------------- |
| `scopedElements` | | `object` | `{
'md-filled-text-field': MdFilledTextField,
'md-switch': MdSwitch,
'md-icon': MdIcon,
'md-icon-button': MdIconButton,
'md-menu': MdMenu,
'md-menu-item': MdMenuItem,
}` | | |

#### Fields

| Name | Privacy | Type | Default | Description | Inherited From |
| ---------------- | ------- | --------------------- | ------------ | ------------------------------------------------------------------------------------------------------------- | -------------- |
| `nullable` | | `boolean` | `false` | Whether \[\[\`value\`]] may be set to \`null\` by nullSwitch | |
| `value` | | `string \| null` | | SCL attributes \`value\`, can only be \`null\` if \[\[\`nullable\`]]. | |
| `disabled` | | `boolean` | `false` | | |
| `label` | | `string` | `''` | | |
| `required` | | `boolean` | `false` | | |
| `supportingText` | | `string` | `''` | | |
| `suffixText` | | `string` | `''` | The inputs suffix text so long there is no \[\[\`unit\`]] defined | |
| `placeholder` | | `string` | `''` | | |
| `type` | | `'number' \| 'text'` | `'text'` | | |
| `pattern` | | `string` | `''` | | |
| `max` | | `string` | `''` | | |
| `min` | | `string` | `''` | | |
| `maxLength` | | `number` | `-1` | | |
| `minLength` | | `number` | `-1` | | |
| `unit` | | `string` | `''` | SI Unit, must be non-empty to allow for selecting a \[\[\`multiplier\`]].&#xA;Overrides \[\[\`suffixText\`]]. | |
| `multipliers` | | `array` | `[null, '']` | Selectable SI multipliers for a non-empty \[\[\`unit\`]]. | |
| `multiplier` | | `string \| null` | | The current selected \[\[\`multiplier\`]] | |
| `nullSwitch` | | `Switch \| undefined` | | | |
| Name | Privacy | Type | Default | Description | Inherited From |
| ---------------- | ------- | ----------------------- | ------------ | ------------------------------------------------------------------------------------------------------------- | -------------- |
| `nullable` | | `boolean` | `false` | Whether \[\[\`value\`]] may be set to \`null\` by nullSwitch | |
| `value` | | `string \| null` | | SCL attributes \`value\`, can only be \`null\` if \[\[\`nullable\`]]. | |
| `disabled` | | `boolean` | `false` | | |
| `label` | | `string` | `''` | | |
| `required` | | `boolean` | `false` | | |
| `supportingText` | | `string` | `''` | | |
| `suffixText` | | `string` | `''` | The inputs suffix text so long there is no \[\[\`unit\`]] defined | |
| `placeholder` | | `string` | `''` | | |
| `type` | | `'number' \| 'text'` | `'text'` | | |
| `pattern` | | `string` | `''` | | |
| `max` | | `string` | `''` | | |
| `min` | | `string` | `''` | | |
| `maxLength` | | `number` | `-1` | | |
| `minLength` | | `number` | `-1` | | |
| `unit` | | `string` | `''` | SI Unit, must be non-empty to allow for selecting a \[\[\`multiplier\`]].&#xA;Overrides \[\[\`suffixText\`]]. | |
| `multipliers` | | `array` | `[null, '']` | Selectable SI multipliers for a non-empty \[\[\`unit\`]]. | |
| `multiplier` | | `string \| null` | | The current selected \[\[\`multiplier\`]] | |
| `nullSwitch` | | `MdSwitch \| undefined` | | | |

#### Methods

Expand Down Expand Up @@ -66,7 +85,7 @@ This element was meant to be used only for plugins in this organization. If it s
| `isNull` | private | `boolean` | `false` | | |
| `parkedValue` | private | `string \| null` | `null` | | |
| `null` | private | `boolean` | | | |
| `multiplierMenu` | private | `Menu \| undefined` | | | |
| `multiplierMenu` | private | `MdMenu \| undefined` | | | |
| `textField` | private | `TextField \| undefined` | | | |

#### Methods
Expand All @@ -86,9 +105,17 @@ This element was meant to be used only for plugins in this organization. If it s

### Exports

| Kind | Name | Declaration | Module | Package |
| ---- | -------------- | ------------ | ----------------- | ------- |
| `js` | `SclTextField` | SclTextField | scl-text-field.ts | |
| Kind | Name | Declaration | Module | Package |
| ---- | -------------- | ------------ | --------------- | ------- |
| `js` | `SclTextField` | SclTextField | SclTextField.ts | |

## `scl-text-field.ts`:

### Exports

| Kind | Name | Declaration | Module | Package |
| --------------------------- | ---------------- | ------------ | ---------------- | ------- |
| `custom-element-definition` | `scl-text-field` | SclTextField | /SclTextField.js | |


&copy; 2023 The Contributors
Loading

0 comments on commit 1558f51

Please sign in to comment.