Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Change into a slicker Card button icon #6638

Merged
merged 2 commits into from
Apr 2, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 10 additions & 2 deletions panel/models/card.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,14 @@ import type * as p from "@bokehjs/core/properties"

import card_css from "styles/models/card.css"

const CHEVRON_RIGHT = `
<svg xmlns="http://www.w3.org/2000/svg" width="12" height="12" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="3" stroke-linecap="round" stroke-linejoin="round" class="icon icon-tabler icons-tabler-outline icon-tabler-chevron-right"><path stroke="none" d="M0 0h12v12H0z" fill="none"/><path d="M9 6l6 6l-6 6" /></svg>
`

const CHEVRON_DOWN = `
<svg xmlns="http://www.w3.org/2000/svg" width="12" height="12" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="3" stroke-linecap="round" stroke-linejoin="round" class="icon icon-tabler icons-tabler-outline icon-tabler-chevron-down"><path stroke="none" d="M0 0h12v12H0z" fill="none"/><path d="M6 9l6 6l6 -6" /></svg>
`

export class CardView extends ColumnView {
declare model: Card

Expand Down Expand Up @@ -73,7 +81,7 @@ export class CardView extends ColumnView {
if (this.model.collapsible) {
this.button_el = DOM.createElement("button", {type: "button", class: header_css_classes})
const icon = DOM.createElement("div", {class: button_css_classes})
icon.innerHTML = this.model.collapsed ? "\u25ba" : "\u25bc"
icon.innerHTML = this.model.collapsed ? CHEVRON_RIGHT : CHEVRON_DOWN
this.button_el.appendChild(icon)
this.button_el.style.backgroundColor = header_background != null ? header_background : ""
header.el.style.backgroundColor = header_background != null ? header_background : ""
Expand Down Expand Up @@ -136,7 +144,7 @@ export class CardView extends ColumnView {
} else {
this.collapsed_style.clear()
}
this.button_el.children[0].innerHTML = this.model.collapsed ? "\u25ba" : "\u25bc"
this.button_el.children[0].innerHTML = this.model.collapsed ? CHEVRON_RIGHT : CHEVRON_DOWN
this.invalidate_layout()
}

Expand Down
Loading