Skip to content
This repository has been archived by the owner on Nov 22, 2024. It is now read-only.

Experimental/custom elements #144

Merged
merged 15 commits into from
Nov 1, 2020
Merged
Show file tree
Hide file tree
Changes from 10 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,14 @@ All notable changes to this project will be documented in this file.

The format is based on [Keep a Changelog](https://keepachangelog.com/) and this project adheres to [Semantic Versioning](https://semver.org/).

## [Unreleased]

### Added
- All components are now registered as `customElements` as well, meaning that they can be used with Svelte (or any framework). This does not affect any existing usage. More information in [the docs](https://illright.github.io/attractions/docs/customElements).
aabounegm marked this conversation as resolved.
Show resolved Hide resolved

### Changed
- The [`<Button>`](https://github.com/illright/attractions/blob/master/attractions/button/button.svelte)'s `click` event was being forwarded directly instead of the payload being wrapped as with other events. This is changed (in commit 0b549d5cbd4a2c5328d5019886b8a4a25f7b903d) for consistency.

## [2.1.1] - 2020-09-02

Minor documentation and bug fixes.
Expand Down
15 changes: 15 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,21 @@ autoPreprocess({
})
```

---

Alteratively, the library can be used from a CDN, such as unpkg, and then the components will be registered as custom elements. This is especially useful for quick prototypes that do not need all the features provided.
aabounegm marked this conversation as resolved.
Show resolved Hide resolved

Example usage:
```html
<head>
<script src="https://unpkg.com/attractions"></script>
</head>
<body>
<a-button filled="filled">My button</a-button>
</body>
```
For more details, check out [the docs](https://illright.github.io/attractions/docs/customElements).

## Theming

You may configure style parameters such as colors, fonts and shadows by overriding respective variables in your `_attractions-theme.scss` file:
Expand Down
Empty file.
2 changes: 2 additions & 0 deletions attractions/accordion/accordion-section.svelte
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
<svelte:options tag="a-accordion-section" />

<script>
import Button from '../button/button.svelte';
import { createEventDispatcher } from 'svelte';
Expand Down
2 changes: 2 additions & 0 deletions attractions/accordion/accordion.svelte
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
<svelte:options tag="a-accordion" />

<script>
import classes from '../utils/classes.js';

Expand Down
2 changes: 2 additions & 0 deletions attractions/autocomplete/autocomplete-field.svelte
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
<svelte:options tag="a-autocomplete-field" />

<script>
import { createEventDispatcher } from 'svelte';
import DropdownShell from '../dropdown/dropdown-shell.svelte';
Expand Down
2 changes: 2 additions & 0 deletions attractions/autocomplete/autocomplete-option.svelte
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
<svelte:options tag="a-autocomplete-option" />

<script>
import { createEventDispatcher } from 'svelte';

Expand Down
2 changes: 2 additions & 0 deletions attractions/autocomplete/autocomplete.svelte
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
<svelte:options tag="a-autocomplete" />

<script>
import { createEventDispatcher } from 'svelte';
import Button from '../button/button.svelte';
Expand Down
2 changes: 2 additions & 0 deletions attractions/autocomplete/more-horizontal.svelte
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
<!-- More-horizontal icon from the Feather Icons pack: https://feathericons.com/ -->
<svelte:options tag={null} />

<svg
xmlns="http://www.w3.org/2000/svg"
width="24"
Expand Down
2 changes: 2 additions & 0 deletions attractions/badge/badge.svelte
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
<svelte:options tag="a-badge" />

<script>
import classes from '../utils/classes.js';

Expand Down
4 changes: 3 additions & 1 deletion attractions/button/button.svelte
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
<svelte:options tag="a-button" />

<script>
import { createEventDispatcher } from 'svelte';
import ripple from '../utils/ripple.js';
Expand Down Expand Up @@ -71,7 +73,7 @@
class:rectangle
class:small
class:selected
on:click
on:click={(e) => dispatch('click', { nativeEvent: e })}
use:ripple={{ disabled: noRipple || disabled }}
use:eventsAction={events}
{...$$restProps}
Expand Down
2 changes: 0 additions & 2 deletions attractions/button/index.js

This file was deleted.

2 changes: 2 additions & 0 deletions attractions/card/card.svelte
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
<svelte:options tag="a-card" />

<script>
import classes from '../utils/classes.js';

Expand Down
2 changes: 2 additions & 0 deletions attractions/checkbox/checkbox-group.svelte
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
<svelte:options tag="a-checkbox-group" />

<script>
import classes from '../utils/classes.js';
import getColorPickerStyles from '../utils/color-picker-styles.js';
Expand Down
2 changes: 2 additions & 0 deletions attractions/checkbox/checkbox.svelte
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
<svelte:options tag="a-checkbox" />

<script>
import { createEventDispatcher } from 'svelte';
import classes from '../utils/classes.js';
Expand Down
2 changes: 2 additions & 0 deletions attractions/chip/checkbox-chip-group.svelte
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
<svelte:options tag="a-checkbox-chip-group" />

<script>
import s from '../utils/plural-s.js';
import classes from '../utils/classes.js';
Expand Down
2 changes: 2 additions & 0 deletions attractions/chip/checkbox-chip.svelte
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
<svelte:options tag="a-checkbox-chip" />

<script>
import { createEventDispatcher } from 'svelte';
import classes from '../utils/classes.js';
Expand Down
2 changes: 2 additions & 0 deletions attractions/chip/chip.svelte
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
<svelte:options tag="a-chip" />

<script>
import classes from '../utils/classes.js';

Expand Down
2 changes: 2 additions & 0 deletions attractions/chip/radio-chip-group.svelte
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
<svelte:options tag="a-radio-chip-group" />

<script>
import classes from '../utils/classes.js';
import RadioChip from './radio-chip.svelte';
Expand Down
2 changes: 2 additions & 0 deletions attractions/chip/radio-chip.svelte
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
<svelte:options tag="a-radio-chip" />

<script>
import { createEventDispatcher } from 'svelte';
import classes from '../utils/classes.js';
Expand Down
2 changes: 2 additions & 0 deletions attractions/date-picker/calendar.svelte
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
<svelte:options tag="a-calendar" />

<script>
import Button from '../button/button.svelte';
import { createEventDispatcher } from 'svelte';
Expand Down
2 changes: 2 additions & 0 deletions attractions/date-picker/chevron-left.svelte
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
<!-- Chevron-left icon from the Feather Icons pack: https://feathericons.com/ -->
<svelte:options tag={null} />

<svg
xmlns="http://www.w3.org/2000/svg"
width="24"
Expand Down
2 changes: 2 additions & 0 deletions attractions/date-picker/chevron-right.svelte
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
<!-- Chevron-right icon from the Feather Icons pack: https://feathericons.com/ -->
<svelte:options tag={null} />

<svg
xmlns="http://www.w3.org/2000/svg"
width="24"
Expand Down
2 changes: 2 additions & 0 deletions attractions/date-picker/date-picker.svelte
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
<svelte:options tag="a-date-picker" />

<script>
import { createEventDispatcher } from 'svelte';
import classes from '../utils/classes.js';
Expand Down
2 changes: 2 additions & 0 deletions attractions/dialog/dialog.svelte
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
<svelte:options tag="a-dialog" />

<script>
import Button from '../button/button.svelte';
import X from './x.svelte';
Expand Down
2 changes: 2 additions & 0 deletions attractions/dialog/x.svelte
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
<!-- X icon from the Feather Icons pack: https://feathericons.com/ -->
<svelte:options tag={null} />

<svg
xmlns="http://www.w3.org/2000/svg"
width="24"
Expand Down
2 changes: 2 additions & 0 deletions attractions/divider/divider.svelte
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
<svelte:options tag="a-divider" />

<script>
export let text = null;
</script>
Expand Down
2 changes: 2 additions & 0 deletions attractions/dot/dot.svelte
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
<svelte:options tag="a-dot" />

<script>
import classes from '../utils/classes.js';

Expand Down
2 changes: 2 additions & 0 deletions attractions/dropdown/dropdown-shell.svelte
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
<svelte:options tag="a-dropdown-shell" />

<script>
import { createEventDispatcher } from 'svelte';
import classes from '../utils/classes.js';
Expand Down
2 changes: 2 additions & 0 deletions attractions/dropdown/dropdown.svelte
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
<svelte:options tag="a-dropdown" />

<script>
import classes from '../utils/classes.js';

Expand Down
2 changes: 2 additions & 0 deletions attractions/file-input/file-dropzone.svelte
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
<svelte:options tag="a-file-dropzone" />

<script>
import Paperclip from './paperclip.svelte';
import Plus from './plus.svelte';
Expand Down
2 changes: 2 additions & 0 deletions attractions/file-input/file-input.svelte
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
<svelte:options tag="a-file-input" />

<script>
import { createEventDispatcher } from 'svelte';
import Button from '../button/button.svelte';
Expand Down
2 changes: 2 additions & 0 deletions attractions/file-input/file-tile.svelte
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
<svelte:options tag="a-file-tile" />

<script>
import Trash2 from './trash-2.svelte';
import Button from '../button/button.svelte';
Expand Down
2 changes: 2 additions & 0 deletions attractions/file-input/paperclip.svelte
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
<!-- Paperclip icon from the Feather Icons pack: https://feathericons.com/ -->
<svelte:options tag={null} />

<script>
import classes from '../utils/classes.js';

Expand Down
2 changes: 2 additions & 0 deletions attractions/file-input/plus.svelte
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
<!-- Plus icon from the Feather Icons pack: https://feathericons.com/ -->
<svelte:options tag={null} />

<script>
import classes from '../utils/classes.js';

Expand Down
2 changes: 2 additions & 0 deletions attractions/file-input/trash-2.svelte
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
<!-- Trash-2 icon from the Feather Icons pack: https://feathericons.com/ -->
<svelte:options tag={null} />

<svg
xmlns="http://www.w3.org/2000/svg"
width="24"
Expand Down
2 changes: 2 additions & 0 deletions attractions/form-field/form-field.svelte
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
<svelte:options tag="a-form-field" />

<script>
import classes from '../utils/classes.js';

Expand Down
2 changes: 2 additions & 0 deletions attractions/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -70,3 +70,5 @@ export { default as AutocompleteField } from './autocomplete/autocomplete-field.
export { default as Badge } from './badge/badge.svelte';

export { default as Pagination } from './pagination/pagination.svelte';

export * as utils from './utils';
2 changes: 2 additions & 0 deletions attractions/loading/loading.svelte
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
<!-- Adapted from SpinKit by @tobiasahlin: https://tobiasahlin.com/spinkit/ -->
<svelte:options tag="a-loading" />

<script>
import classes from '../utils/classes.js';

Expand Down
2 changes: 2 additions & 0 deletions attractions/modal/modal.svelte
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
<svelte:options tag="a-modal" />

<script>
import { createEventDispatcher } from 'svelte';
import classes from '../utils/classes.js';
Expand Down
4 changes: 3 additions & 1 deletion attractions/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -20,10 +20,12 @@
],
"devDependencies": {
"@rollup/plugin-node-resolve": "^9.0.0",
"node-sass": "^4.14.1",
"pkg-versions": "^2.1.0",
"rollup": "^2.18.2",
"rollup-plugin-svelte": "^5.2.3",
"svelte": "^3.23.2"
"svelte": "^3.23.2",
"svelte-preprocess": "^4.5.2"
},
"peerDependencies": {
"node-sass": "^4.14.1",
Expand Down
2 changes: 2 additions & 0 deletions attractions/pagination/pagination.svelte
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
<svelte:options tag="a-pagination" />

<script>
import { createEventDispatcher } from 'svelte';
import Button from '../button/button.svelte';
Expand Down
2 changes: 2 additions & 0 deletions attractions/popover/popover-button.svelte
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
<svelte:options tag="a-popover-button" />

<script>
import { createEventDispatcher } from 'svelte';
import classes from '../utils/classes.js';
Expand Down
2 changes: 2 additions & 0 deletions attractions/popover/popover.svelte
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
<svelte:options tag="a-popover" />

<script>
import classes from '../utils/classes.js';
import PopoverPositions from './popover-positions.js';
Expand Down
2 changes: 2 additions & 0 deletions attractions/radio-button/radio-button.svelte
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
<svelte:options tag="a-radio-button" />

<script>
import { createEventDispatcher } from 'svelte';
import classes from '../utils/classes.js';
Expand Down
2 changes: 2 additions & 0 deletions attractions/radio-button/radio-group.svelte
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
<svelte:options tag="a-radio-group" />

<script>
import classes from '../utils/classes.js';
import getColorPickerStyles from '../utils/color-picker-styles.js';
Expand Down
43 changes: 32 additions & 11 deletions attractions/rollup.config.js
Original file line number Diff line number Diff line change
@@ -1,20 +1,41 @@
import svelte from 'rollup-plugin-svelte';
import resolve from '@rollup/plugin-node-resolve';
import autoPreprocess from 'svelte-preprocess';
import pkg from './package.json';

const name = pkg.name
.replace(/^(@\S+\/)?(svelte-)?(\S+)/, '$3')
.replace(/^\w/, m => m.toUpperCase())
.replace(/-\w/g, m => m[1].toUpperCase());

export default {
input: 'index.js',
output: [
{ file: pkg.module, 'format': 'es' },
{ file: pkg.main, 'format': 'umd', name },
],
plugins: [
svelte(),
resolve(),
],
};
export default [
{
input: 'index.js',
output: [
{ file: pkg.module, 'format': 'es' },
{ file: pkg.main, 'format': 'umd', name },
],
plugins: [
svelte(),
resolve(),
],
},
{
// This will likely replace the other configuration above
aabounegm marked this conversation as resolved.
Show resolved Hide resolved
input: 'index.js',
output: {
file: 'dist/bundle.js',
format: 'iife',
name: 'attractions',
},
plugins: [
svelte({
customElement: true,
preprocess: autoPreprocess({
scss: { includePaths: ['./'] },
}),
}),
resolve(),
],
},
];
2 changes: 2 additions & 0 deletions attractions/snackbar/snackbar-container.svelte
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
<svelte:options tag="a-snackbar-container" />

<script>
import { setContext } from 'svelte';
import Snackbar from './snackbar.svelte';
Expand Down
2 changes: 2 additions & 0 deletions attractions/snackbar/snackbar.svelte
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
<svelte:options tag="a-snackbar" />

<script>
import Button from '../button/button.svelte';
import { fly } from 'svelte/transition';
Expand Down
2 changes: 2 additions & 0 deletions attractions/star-rating/star-rating.svelte
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
<svelte:options tag="a-star-rating" />

<script>
import { createEventDispatcher } from 'svelte';
import Star from './star.svelte';
Expand Down
2 changes: 2 additions & 0 deletions attractions/star-rating/star.svelte
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
<!-- Star icon from the Feather Icons pack: https://feathericons.com/ -->
<svelte:options tag={null} />

<svg
xmlns="http://www.w3.org/2000/svg"
width="24"
Expand Down
Loading