atagen

malice

public
Star0
Watch0
7643577c76bbdca0b730c4669d326ba822782733
2
ssh://brewery@pls.lobotomise.me:33/atagen/malice.git
web/src/lib/PinButton.svelteSvelte45 lines1.1 KB
1
<script lang="ts">
2
  export let pinned: boolean;
3
  export let label: string;
4
  export let onToggle: () => void;
5
</script>
6
7
<button
8
  type="button"
9
  class="pin-btn"
10
  class:pinned
11
  aria-pressed={pinned}
12
  aria-label={pinned ? `Unpin ${label}` : `Pin ${label}`}
13
  title={pinned ? 'Unpin' : 'Pin'}
14
  on:click={onToggle}
15
>
16
  <svg viewBox="0 0 24 24" width="14" height="14" aria-hidden="true">
17
    <path
18
      d="M9 3h6l-1 6 4 4v2h-5v6l-1 1-1-1v-6H6v-2l4-4z"
19
      fill={pinned ? 'currentColor' : 'none'}
20
      stroke="currentColor"
21
      stroke-width="1.8"
22
      stroke-linejoin="round"
23
    />
24
  </svg>
25
</button>
26
27
<style>
28
  .pin-btn {
29
    flex: none;
30
    display: grid;
31
    place-items: center;
32
    width: 24px;
33
    height: 24px;
34
    padding: 0;
35
    border: none;
36
    border-radius: var(--r-sm);
37
    background: transparent;
38
    color: var(--muted);
39
    cursor: pointer;
40
    opacity: 0;
41
  }
42
  .pin-btn.pinned { opacity: 1; color: var(--accent); }
43
  .pin-btn:hover { background: var(--hover); color: var(--text); }
44
  :global(.room-item:hover) .pin-btn, :global(.room-item:focus-within) .pin-btn, .pin-btn:focus-visible { opacity: 1; }
45
</style>