Skip to content

Commit

Permalink
fix: event part in storybook fixed
Browse files Browse the repository at this point in the history
  • Loading branch information
tshimber committed Aug 30, 2024
1 parent 8a694a2 commit af143b0
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -72,12 +72,12 @@ You should now be able to use Scale components in your templates:

## Events in Angular

In order to prevent collisions with standard events and for better compatibility with other libraries and frameworks, the custom events emitted by some Scale components are prefixed with `scale`. Event names are camelCased (e.g. `scaleChange`). You can find the documentation on these custom events on the respective component pages in the "docs" section.
In order to prevent collisions with standard events and for better compatibility with other libraries and frameworks, the custom events emitted by some Scale components are prefixed with `scale`. Event names are kebab-cased (e.g. scale-change). Note, that before v3 events were camelCased (e.g. `scaleChange`), these are now deprecated, but still available for maintaining backward compatibility. For newest components only kebab-case events apply. You can find the documentation to custom events on the respective component pages in the "docs" section.

You can bind to `scale`-prefixed events with the regular Angular syntax:

```html
<scale-slider (scaleInput)="setValue($event)"></scale-slider>
<scale-slider (scale-input)="setValue($event)"></scale-slider>
```

## Reactive Forms
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -82,17 +82,19 @@ const App = () => {
const handleInput = (event) => {
// it works!
};
return <ScaleSlider label="Example" onScaleInput={handleInput}></ScaleSlider>;
return (
<ScaleSlider label="Example" on-scale-input={handleInput}></ScaleSlider>
);
};

export default App;
```

Please note that when using any custom events from scale in a wrapper, it is important to include "on" before the event name. For example, "scaleChange" should be written as "onScaleChange.
Please note that when using any custom events from scale in a wrapper, it is important to include "on" before the event name. For example, "scale-change" should be written as "on-scale-change".

## Events in React

In order to prevent collisions with standard events and for better compatibility with other libraries and frameworks, the custom events emitted by some Scale components are prefixed with `scale`. Event names are camelCased (e.g. `scaleChange`). You can find the documentation for these custom events on the respective component pages in the "docs" section.
In order to prevent collisions with standard events and for better compatibility with other libraries and frameworks, the custom events emitted by some Scale components are prefixed with `scale`. Event names are kebab-cased (e.g. scale-change). Note, that before v3 events were camelCased (e.g. `scaleChange`), these are now deprecated, but still available for maintaining backward compatibility. For newest components only kebab-case events apply. You can find the documentation to custom events on the respective component pages in the "docs" section.

Due to React's [synthetic events](https://reactjs.org/docs/handling-events.html), binding to custom events requires some extra work. You can use an interop layer like the ones listed above, or alternatively use [`ref`](https://reactjs.org/docs/refs-and-the-dom.html) to bind imperatively with `addEventListener`.

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -100,12 +100,12 @@ You should now be able to use Scale components in your templates:

## Events in Vue

In order to prevent collisions with standard events and for better compatibility with other libraries and frameworks, the custom events emitted by some Scale components are prefixed with `scale`. Event names are camelCased (e.g. `scaleChange`). You can find the documentation for these custom events on the respective component pages in the "docs" section.
In order to prevent collisions with standard events and for better compatibility with other libraries and frameworks, the custom events emitted by some Scale components are prefixed with `scale`. Event names are kebab-cased (e.g. scale-change). Note, that before v3 events were camelCased (e.g. `scaleChange`), these are now deprecated, but still available for maintaining backward compatibility. For newest components only kebab-case events apply. You can find the documentation to custom events on the respective component pages in the "docs" section.

You can bind to `scale`-prefixed events with the regular Vue syntax:

```html
<scale-slider @scaleInput="handleInput"></scale-slider>
<scale-slider @scale-input="handleInput"></scale-slider>
```

## Form Input Bindings
Expand Down

0 comments on commit af143b0

Please sign in to comment.