Skip to content

Commit 76691af

Browse files
committed
feat(rotary-dialer): add pins
1 parent e5726e4 commit 76691af

File tree

2 files changed

+35
-18
lines changed

2 files changed

+35
-18
lines changed

src/rotary-dailer-element.stories.ts

Lines changed: 13 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,17 @@
11
import { action } from '@storybook/addon-actions';
2-
import { withKnobs } from '@storybook/addon-knobs';
3-
import { storiesOf } from '@storybook/web-components';
42
import { html } from 'lit';
53
import './rotary-dialer-element';
64

7-
storiesOf('Rotary Dialer', module)
8-
.addParameters({ component: 'wokwi-rotary-dialer' })
9-
.addDecorator(withKnobs)
10-
.add(
11-
'Default',
12-
() =>
13-
html`
14-
<wokwi-rotary-dialer
15-
@dial=${action('dial')}
16-
@dial-start=${action('dial-start')}
17-
@dial-end=${action('dial-end')}
18-
></wokwi-rotary-dialer>
19-
`
20-
);
5+
export default {
6+
title: 'Rotary Dialer',
7+
component: 'wokwi-rotary-dialer',
8+
};
9+
10+
export const Default = () =>
11+
html`
12+
<wokwi-rotary-dialer
13+
@dial=${action('dial')}
14+
@dial-start=${action('dial-start')}
15+
@dial-end=${action('dial-end')}
16+
></wokwi-rotary-dialer>
17+
`;

src/rotary-dialer-element.ts

Lines changed: 22 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,16 +2,24 @@ import { css, html, LitElement } from 'lit';
22
import { customElement } from 'lit/decorators.js';
33
import { classMap } from 'lit/directives/class-map.js';
44
import { styleMap } from 'lit/directives/style-map.js';
5+
import { ElementPin, GND } from './pin';
56

67
type InitialValue = '';
78
type Digit = 0 | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9;
89

910
@customElement('wokwi-rotary-dialer')
1011
export class RotaryDialerElement extends LitElement {
12+
readonly pinInfo: ElementPin[] = [
13+
{ name: 'GND', x: 122, y: 286, signals: [GND()] },
14+
{ name: 'DIAL', x: 131.6, y: 286, signals: [] },
15+
{ name: 'PULSE', x: 141.2, y: 286, signals: [] },
16+
];
17+
1118
private digit: Digit | InitialValue = '';
1219
private stylesMapping = {};
1320
private classes: Record<string, boolean> = { 'rotate-path': true };
1421
private degrees = [320, 56, 87, 115, 143, 173, 204, 232, 260, 290];
22+
1523
static get styles() {
1624
return css`
1725
.text {
@@ -30,7 +38,7 @@ export class RotaryDialerElement extends LitElement {
3038
margin: -1px;
3139
}
3240
.rotate-path {
33-
transform-origin: center;
41+
transform-origin: 133px 133px;
3442
transition: transform 1000ms ease-in;
3543
}
3644
.dialer-anim {
@@ -87,7 +95,19 @@ export class RotaryDialerElement extends LitElement {
8795
value="${this.digit}"
8896
@input="${this.onValueChange}"
8997
/>
90-
<svg width="266" height="266" @click="${this.focusInput}" xmlns="http://www.w3.org/2000/svg">
98+
<svg width="266" height="286" @click="${this.focusInput}" xmlns="http://www.w3.org/2000/svg">
99+
<!-- Pins -->
100+
<g fill="#9f9f9f" stroke-width=".987">
101+
<path
102+
d="m123.4 266c0-0.377-0.149-0.739-0.416-1.01-0.268-0.267-0.629-0.417-1.01-0.417-0.377 0-0.739 0.15-1.01 0.417s-0.417 0.629-0.417 1.01v25.8c0 0.231 0.188 0.419 0.418 0.419h2.01c0.231 0 0.418-0.188 0.418-0.419v-25.8z"
103+
/>
104+
<path
105+
d="m133 266c0-0.377-0.149-0.739-0.416-1.01-0.268-0.267-0.629-0.417-1.01-0.417-0.377 0-0.739 0.15-1.01 0.417s-0.417 0.629-0.417 1.01v25.8c0 0.231 0.188 0.419 0.418 0.419h2.01c0.231 0 0.418-0.188 0.418-0.419v-25.8z"
106+
/>
107+
<path
108+
d="m142.6 266c0-0.377-0.15-0.739-0.417-1.01s-0.629-0.417-1.01-0.417c-0.377 0-0.739 0.15-1.01 0.417s-0.417 0.629-0.417 1.01v25.8c0 0.231 0.188 0.419 0.419 0.419h2.01c0.231 0 0.419-0.188 0.419-0.419v-25.8z"
109+
/>
110+
</g>
91111
<g transform="translate(1 1)">
92112
<circle stroke="#979797" stroke-width="3" fill="#1F1F1F" cx="133" cy="133" r="131" />
93113
<circle stroke="#fff" stroke-width="2" fill="#D8D8D8" cx="133" cy="133" r="72" />

0 commit comments

Comments
 (0)