Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

turn fancybutton into custombutton #4476

Merged
merged 4 commits into from
Feb 27, 2020
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
<script>
import FancyButton from './FancyButton.svelte';
import CustomButton from './CustomButton.svelte';

function handleClick() {
alert('clicked');
}
</script>

<FancyButton on:click={handleClick}/>
<CustomButton on:click={handleClick}/>
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
<style>
button {
height: 4rem;
width: 8rem;
background-color: #aaa;
border-color: #f1c40f;
color: #f1c40f;
font-size: 1.25rem;
background-image: linear-gradient(45deg, #f1c40f 50%, transparent 50%);
background-position: 100%;
background-size: 400%;
transition: background 300ms ease-in-out;
}
button:hover {
background-position: 0;
color: #aaa;
}
</style>

<button on:click>
Click me
</button>
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
<script>
import FancyButton from './FancyButton.svelte';
import CustomButton from './CustomButton.svelte';

function handleClick() {
alert('clicked');
}
</script>

<FancyButton on:click={handleClick}/>
<CustomButton on:click={handleClick}/>
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
<style>
button {
height: 4rem;
width: 8rem;
background-color: #aaa;
border-color: #f1c40f;
color: #f1c40f;
font-size: 1.25rem;
background-image: linear-gradient(45deg, #f1c40f 50%, transparent 50%);
background-position: 100%;
background-size: 400%;
transition: background 300ms ease-in-out;
}
button:hover {
background-position: 0;
color: #aaa;
}
</style>

<button>
Click me
</button>

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
<script>
import FancyButton from './FancyButton.svelte';
import CustomButton from './CustomButton.svelte';

function handleClick() {
alert('clicked');
}
</script>

<FancyButton on:click={handleClick}/>
<CustomButton on:click={handleClick}/>

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ title: DOM event forwarding

Event forwarding works for DOM events too.

We want to get notified of clicks on our `<FancyButton>` — to do that, we just need to forward `click` events on the `<button>` element in `FancyButton.svelte`:
We want to get notified of clicks on our `<CustomButton>` — to do that, we just need to forward `click` events on the `<button>` element in `CustomButton.svelte`:

```html
<button on:click>
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
class CustomButton extends HTMLButtonElement {}
customElements.define('custom-button', CustomButton, { extends: 'button' });
2 changes: 0 additions & 2 deletions test/custom-elements/samples/extended-builtin/fancy-button.js

This file was deleted.

4 changes: 2 additions & 2 deletions test/custom-elements/samples/extended-builtin/main.svelte
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<svelte:options tag="custom-element"/>

<script>
import './fancy-button.js';
import './custom-button.js';
</script>

<button is="fancy-button">click me</button>
<button is="custom-button">click me</button>
2 changes: 1 addition & 1 deletion test/custom-elements/samples/extended-builtin/test.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,5 +11,5 @@ export default function (target) {
const el = target.querySelector('custom-element');
const button = el.shadowRoot.querySelector('button');

assert.ok(button instanceof customElements.get('fancy-button'));
assert.ok(button instanceof customElements.get('custom-button'));
}