-
Notifications
You must be signed in to change notification settings - Fork 47
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
380f454
commit 9620a66
Showing
5 changed files
with
323 additions
and
20 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
import { UUIEvent } from '@umbraco-ui/uui-base/lib/events'; | ||
import { UUICopyElement } from './uui-copy.element'; | ||
|
||
export class UUICopyEvent extends UUIEvent<{ text: string }, UUICopyElement> { | ||
public static readonly COPIED: string = 'copied'; | ||
public static readonly COPYING: string = 'copying'; | ||
|
||
constructor(evName: string, eventInit: any | null = {}) { | ||
super(evName, { | ||
...{ bubbles: true }, | ||
...eventInit, | ||
}); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,24 +1,187 @@ | ||
import type { Meta, StoryObj } from '@storybook/web-components'; | ||
|
||
import './uui-copy.element'; | ||
import type { UUICopyElement } from './uui-copy.element'; | ||
import readme from '../README.md?raw'; | ||
import { html } from 'lit'; | ||
import { UUICopyEvent } from './UUICopyEvent'; | ||
|
||
const meta: Meta<UUICopyElement> = { | ||
id: 'uui-copy', | ||
title: 'Copy', | ||
title: 'Inputs/Copy', | ||
component: 'uui-copy', | ||
parameters: { | ||
readme: { markdown: readme }, | ||
}, | ||
}; | ||
|
||
export default meta; | ||
type Story = StoryObj<UUICopyElement>; | ||
|
||
export const Overview: Story = { | ||
name: 'Simple Copy', | ||
args: { | ||
value: 'Hey stop copying me 🥸', | ||
disabled: false, | ||
}, | ||
parameters: { | ||
docs: { | ||
source: { | ||
code: `<uui-copy></uui-copy>`, | ||
code: `<uui-copy value="Hey stop copying me 🥸"></uui-copy>`, | ||
}, | ||
}, | ||
}, | ||
}; | ||
|
||
export default meta; | ||
type Story = StoryObj<UUICopyElement>; | ||
export const Disabled: Story = { | ||
name: 'Disabled State', | ||
args: { | ||
value: 'You cannot copy this', | ||
disabled: true, | ||
}, | ||
parameters: { | ||
docs: { | ||
source: { | ||
code: `<uui-copy value="You cannot copy this" disabled></uui-copy>`, | ||
}, | ||
}, | ||
}, | ||
}; | ||
|
||
export const CustomSlotContent: Story = { | ||
name: 'Custom Slot Content', | ||
args: { | ||
value: 'Custom slot content', | ||
}, | ||
render: args => html` | ||
<uui-copy .value=${args.value}> Custom Copy Text </uui-copy> | ||
`, | ||
parameters: { | ||
docs: { | ||
source: { | ||
code: `<uui-copy value="Custom slot content">Custom Copy Text</uui-copy>`, | ||
}, | ||
}, | ||
}, | ||
}; | ||
|
||
export const Overview: Story = {}; | ||
export const ColorAndLook: Story = { | ||
name: 'Color and Look', | ||
args: { | ||
value: 'Copy this text', | ||
color: 'positive', | ||
look: 'primary', | ||
}, | ||
render: args => html` | ||
<uui-copy .value=${args.value} .color=${args.color} .look=${args.look}> | ||
<uui-icon name="copy"></uui-icon> Copy | ||
</uui-copy> | ||
`, | ||
parameters: { | ||
docs: { | ||
source: { | ||
code: ` | ||
<uui-copy value="I have the same look and color props as UUI-Button" color="positive" look="primary"></uui-copy> | ||
`, | ||
}, | ||
}, | ||
}, | ||
}; | ||
|
||
export const CopiedEvent: Story = { | ||
name: 'Copied Event', | ||
args: { | ||
value: 'Copy this text', | ||
}, | ||
render: args => html` | ||
<uui-copy | ||
.value=${args.value} | ||
@copied=${(event: UUICopyEvent) => { | ||
alert(`Copied text: ${event.detail.text}`); | ||
}}></uui-copy> | ||
`, | ||
parameters: { | ||
docs: { | ||
source: { | ||
code: ` | ||
<uui-copy value="Copy this text"></uui-copy> | ||
<script> | ||
document.querySelector('uui-copy').addEventListener('copied', (event) => { | ||
alert(\`Copied text: \${event.detail.text}\`); | ||
}); | ||
</script> | ||
`, | ||
}, | ||
}, | ||
}, | ||
}; | ||
|
||
export const ModifyClipboardContent: Story = { | ||
name: 'Modify Clipboard Content', | ||
args: { | ||
value: 'Original text', | ||
}, | ||
render: args => html` | ||
<uui-copy | ||
.value=${args.value} | ||
@copying=${(event: UUICopyEvent) => { | ||
event.detail.text += ' - Modified before copying'; | ||
}}> | ||
<uui-icon name="copy"></uui-icon> Copy | ||
</uui-copy> | ||
`, | ||
parameters: { | ||
docs: { | ||
source: { | ||
code: ` | ||
<uui-copy value="Original text"></uui-copy> | ||
<script> | ||
document.querySelector('uui-copy').addEventListener('copying', (event) => { | ||
event.detail.text += ' - Modified before copying'; | ||
}); | ||
</script> | ||
`, | ||
}, | ||
}, | ||
}, | ||
}; | ||
|
||
export const EmptyValueErrorState: Story = { | ||
name: 'Empty Value - shows an Error State', | ||
args: { | ||
value: '', | ||
}, | ||
render: args => html` <uui-copy .value=${args.value}></uui-copy> `, | ||
parameters: { | ||
docs: { | ||
source: { | ||
code: ` | ||
<uui-copy value=""></uui-copy> | ||
`, | ||
}, | ||
}, | ||
}, | ||
}; | ||
|
||
export const CopyFromInput: Story = { | ||
name: 'Copy From uui-input', | ||
render: () => html` | ||
<uui-input id="inputToCopy" placeholder="Type something"> | ||
<uui-copy copy-from="inputToCopy" slot="append" compact> | ||
<uui-icon name="copy"></uui-icon> | ||
</uui-copy> | ||
</uui-input> | ||
`, | ||
parameters: { | ||
docs: { | ||
source: { | ||
code: ` | ||
<uui-input id="inputToCopy" placeholder="Type something"> | ||
<uui-copy copy-from="inputToCopy" slot="append" compact> | ||
<uui-icon name="copy"></uui-icon> | ||
</uui-copy> | ||
</uui-input> | ||
`, | ||
}, | ||
}, | ||
}, | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters