|
| 1 | +import { WebComponent } from 'solid-ui' |
| 2 | +import { customElement } from 'lit/decorators.js' |
| 3 | +import { html } from 'lit' |
| 4 | +import 'solid-ui/components/button' |
| 5 | +import { consume } from '@lit/context' |
| 6 | +import { sourceContext, SourceContext } from '../../primitives/context' |
| 7 | +import '~icons/lucide/share-2' |
| 8 | +import '~icons/lucide/pencil' |
| 9 | +import '~icons/lucide/ellipsis-vertical' |
| 10 | +import styles from './SourceHeaderControls.styles.css' |
| 11 | +import './SourceHeaderSummary' |
| 12 | + |
| 13 | +@customElement('source-pane-source-header-controls') |
| 14 | +export default class SourceHeaderControls extends WebComponent { |
| 15 | + static styles = styles |
| 16 | + |
| 17 | + @consume({ context: sourceContext, subscribe: true }) |
| 18 | + accessor sourceContext: SourceContext = undefined as unknown as SourceContext |
| 19 | + |
| 20 | + /* private canEditSource (subject: NamedNode, sourcePaneState: SourcePaneState) { |
| 21 | + const { allowed } = sourcePaneState |
| 22 | + return !subject.uri.endsWith('/') && (!allowed || allowed.includes('PUT')) |
| 23 | + } */ |
| 24 | + |
| 25 | + private setEditable() { |
| 26 | + const sourcePaneState = this.sourceContext?.sourcePaneState |
| 27 | + const { canEdit } = this.sourceContext?.headerMetadata ?? { canEdit: false } |
| 28 | + const subject = this.sourceContext?.subject |
| 29 | + if (!sourcePaneState || !canEdit || sourcePaneState.broken || (subject && subject.endsWith('/'))) return |
| 30 | + |
| 31 | + this.sourceContext?.setEditing?.() |
| 32 | + } |
| 33 | + |
| 34 | + render () { |
| 35 | + return html` |
| 36 | + <div> |
| 37 | + <solid-ui-button class="sourcePanePrettyButton" variant="ghost" title="Share"> |
| 38 | + <icon-lucide-share-2 slot="icon"></icon-lucide-share-2> |
| 39 | + </solid-ui-button> |
| 40 | + <solid-ui-button class="sourcePanePrettyButton" variant="ghost" @click=${() => this.setEditable()}> |
| 41 | + <icon-lucide-pencil slot="icon"></icon-lucide-pencil> |
| 42 | + </solid-ui-button> |
| 43 | + <solid-ui-button class="sourcePanePrettyButton" variant="ghost" title="More options"> |
| 44 | + <icon-lucide-ellipsis-vertical slot="icon"></icon-lucide-ellipsis-vertical> |
| 45 | + </solid-ui-button> |
| 46 | + </div> |
| 47 | + ` |
| 48 | + } |
| 49 | +} |
0 commit comments