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; filled = false;
@property({ type: String }) @property({ type: String })
size: "small" | "medium" = "medium"; size: "x-small" | "small" | "medium" = "medium";
@property({ type: String }) @property({ type: String })
label?: string; label?: string;
@ -68,10 +68,12 @@ export class Button extends TailwindElement {
return html`<${tag} return html`<${tag}
type=${this.type === "submit" ? "submit" : "button"} type=${this.type === "submit" ? "submit" : "button"}
class=${clsx( 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`, 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`,
this.size === "medium" {
? tw`min-h-8 min-w-8 rounded-sm` "x-small": tw`min-h-4 min-w-4 text-sm`,
: tw`min-h-6 min-w-6 rounded-md`, 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.raised && tw`border shadow-sm`,
this.filled this.filled
? [ ? [

View File

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

View File

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

View File

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

View File

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