Emma Segal-Grossman 2024-05-22 15:55:52 -04:00 committed by GitHub
parent 0d53771a81
commit 2c9ead718f
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
6 changed files with 29 additions and 13 deletions

View File

@ -35,7 +35,7 @@ export class Button extends TailwindElement {
filled = false;
@property({ type: String })
size: "small" | "medium" = "medium";
size: "x-small" | "small" | "medium" = "medium";
@property({ type: String })
label?: string;
@ -68,10 +68,12 @@ export class Button extends TailwindElement {
return html`<${tag}
type=${this.type === "submit" ? "submit" : "button"}
class=${clsx(
tw`flex h-6 cursor-pointer items-center justify-center gap-2 text-center font-medium outline-3 outline-offset-1 outline-primary transition focus-visible:outline disabled:cursor-not-allowed disabled:text-neutral-300`,
this.size === "medium"
? tw`min-h-8 min-w-8 rounded-sm`
: tw`min-h-6 min-w-6 rounded-md`,
tw`flex cursor-pointer items-center justify-center gap-2 text-center font-medium outline-3 outline-offset-1 outline-primary transition focus-visible:outline disabled:cursor-not-allowed disabled:text-neutral-300`,
{
"x-small": tw`min-h-4 min-w-4 text-sm`,
small: tw`min-h-6 min-w-6 rounded-md text-base`,
medium: tw`min-h-8 min-w-8 rounded-sm text-lg`,
}[this.size],
this.raised && tw`border shadow-sm`,
this.filled
? [

View File

@ -1,7 +1,9 @@
import { localized, msg } from "@lit/localize";
import { html, LitElement } from "lit";
import { html } from "lit";
import { customElement, property, state } from "lit/decorators.js";
import { TailwindElement } from "@/classes/TailwindElement";
/**
* Copy text to clipboard on click
*
@ -18,7 +20,7 @@ import { customElement, property, state } from "lit/decorators.js";
*/
@localized()
@customElement("btrix-copy-button")
export class CopyButton extends LitElement {
export class CopyButton extends TailwindElement {
@property({ type: String })
value?: string;
@ -34,6 +36,12 @@ export class CopyButton extends LitElement {
@property({ type: Boolean })
hoist = false;
@property({ type: Boolean })
raised = false;
@property({ type: String })
size: "x-small" | "small" | "medium" = "small";
@state()
private isCopied = false;
@ -61,15 +69,16 @@ export class CopyButton extends LitElement {
@sl-after-hide=${this.stopProp}
>
<btrix-button
size="small"
size=${this.size}
@click=${this.onClick}
?disabled=${!this.value && !this.getValue}
class="inline"
raised
?raised=${this.raised}
>
<sl-icon
name=${this.isCopied ? "check-lg" : this.name ? this.name : "copy"}
label=${msg("Copy to clipboard")}
class="size-3.5"
></sl-icon>
</btrix-button>
</sl-tooltip>

View File

@ -85,6 +85,7 @@ export class CopyField extends TailwindElement {
.getValue=${this.getValue}
.hoist=${this.hoist}
class="m-1 flex"
raised
></btrix-copy-button>
</div>
</div>

View File

@ -476,7 +476,7 @@ export class App extends LiteElement {
>
<sl-icon
name="github"
class="inline-block align-middle text-base"
class="inline-block size-4 align-middle text-base"
></sl-icon>
Source Code
</a>
@ -490,7 +490,7 @@ export class App extends LiteElement {
>
<sl-icon
name="book-half"
class="inline-block align-middle text-base"
class="inline-block size-4 align-middle text-base"
></sl-icon>
Documentation
</a>
@ -499,9 +499,10 @@ export class App extends LiteElement {
${this.version
? html`
<btrix-copy-button
class="text-neutral-400"
class="mr-2 size-4 text-neutral-400"
.getValue=${() => this.version}
content=${msg("Copy Version Code")}
size="x-small"
></btrix-copy-button>
<span
class="font-monostyle inline-block align-middle text-xs text-neutral-400"

View File

@ -842,7 +842,8 @@ export class ArchivedItemQA extends TailwindElement {
placement="bottom-start"
>
<btrix-button
icon
size="small"
class="m-0.5"
@click=${() => {
if (
this.interactiveReplayFrame?.contentDocument

View File

@ -330,6 +330,7 @@ export class CollectionDetail extends LiteElement {
.getValue=${() => embedCode}
content=${msg("Copy Embed Code")}
hoist
raised
></btrix-copy-button>
</div>
</div>
@ -346,6 +347,7 @@ export class CollectionDetail extends LiteElement {
.getValue=${() => importCode}
content=${msg("Copy JS")}
hoist
raised
></btrix-copy-button>
</div>
</div>