Skip to content

Commit

Permalink
Add KolButton and KolButtonLink
Browse files Browse the repository at this point in the history
  • Loading branch information
sdvg committed Nov 17, 2023
1 parent 335b4ad commit eb28412
Show file tree
Hide file tree
Showing 4 changed files with 33 additions and 2 deletions.
2 changes: 2 additions & 0 deletions packages/components/src/components.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -335,6 +335,7 @@ export namespace Components {
* Defines which variant should be used for presentation.
*/
"_variant"?: ButtonVariantPropType;
"getValue": () => Promise<Stringified<StencilUnknown> | undefined>;
}
interface KolButtonGroup {
}
Expand Down Expand Up @@ -413,6 +414,7 @@ export namespace Components {
* Defines the value that the button emits on click.
*/
"_value"?: Stringified<StencilUnknown>;
"getValue": () => Promise<Stringified<StencilUnknown> | undefined>;
}
/**
* Internal component that renders an action or text component like a button or a link.
Expand Down
8 changes: 7 additions & 1 deletion packages/components/src/components/button-link/component.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { Component, Element, h, Host, JSX, Prop } from '@stencil/core';
import { Component, Element, h, Host, JSX, Method, Prop } from '@stencil/core';

import { Stringified } from '../../types/common';
import { AlternativeButtonLinkRolePropType } from '../../types/props/alternative-button-link-role';
Expand Down Expand Up @@ -29,6 +29,12 @@ export class KolButtonLink implements Props {
propagateFocus(this.host, ref);
};

// eslint-disable-next-line @typescript-eslint/require-await
@Method()
public async getValue(): Promise<Stringified<StencilUnknown> | undefined> {
return this._value;
}

public render(): JSX.Element {
return (
<Host>
Expand Down
8 changes: 7 additions & 1 deletion packages/components/src/components/button/shadow.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { Component, Element, h, Host, JSX, Prop } from '@stencil/core';
import { Component, Element, h, Host, JSX, Method, Prop } from '@stencil/core';

import { Stringified } from '../../types/common';
import { AlternativeButtonLinkRolePropType } from '../../types/props/alternative-button-link-role';
Expand Down Expand Up @@ -29,6 +29,12 @@ export class KolButton implements Props {
propagateFocus(this.host, ref);
};

// eslint-disable-next-line @typescript-eslint/require-await
@Method()
public async getValue(): Promise<Stringified<StencilUnknown> | undefined> {
return this._value;
}

public render(): JSX.Element {
return (
<Host>
Expand Down
17 changes: 17 additions & 0 deletions packages/samples/react/src/scenarios/inputs-get-value.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ import {
KolInputText,
KolSelect,
KolTextarea,
KolButtonLink,
} from '@public-ui/react';
import { SampleDescription } from '../components/SampleDescription';

Expand Down Expand Up @@ -118,6 +119,22 @@ export const InputsGetValue: FC = () => {
_label: 'KolTextarea',
}}
/>
<Scenario
InputComponent={KolButton}
inputProps={{
_label: 'KolButton',
_variant: 'ghost',
_value: 'KolButton value',
}}
/>
<Scenario
InputComponent={KolButtonLink}
inputProps={{
_label: 'KolButtonLink',
_value: 'KolButtonLink value',
}}
/>

<div className="grid grid-cols-3 gap-4">
<div></div>
<KolButton
Expand Down

0 comments on commit eb28412

Please sign in to comment.