Skip to content

Commit

Permalink
improve icons
Browse files Browse the repository at this point in the history
  • Loading branch information
ug.rp committed Apr 21, 2024
1 parent 6379ce4 commit bf5711c
Show file tree
Hide file tree
Showing 6 changed files with 48 additions and 34 deletions.
10 changes: 9 additions & 1 deletion public/themes/classic.css
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,14 @@ r4-app[color-scheme='dark'] button {
box-shadow: none;
}

r4-layout::part(playback) {
position: sticky;
top: 0;
}
r4-layout::part(playback-summary) {
background-color: var(--c-bg2);
}

/* pages */
r4-page-header {
/* display: flex; */
Expand All @@ -122,7 +130,7 @@ r4-page-header menu {
}
r4-page-header h1 {
margin: 0;
padding: var(--s);
padding: calc(var(--s) / 2);
}
/* Differentiate channels and track lists by using a grid */
r4-page-explore r4-page-main > r4-list {
Expand Down
10 changes: 8 additions & 2 deletions src/components/r4-button-follow.js
Original file line number Diff line number Diff line change
Expand Up @@ -28,13 +28,19 @@ export default class R4ButtonFollow extends LitElement {
renderUnfollow() {
return html`
<button @click=${this.unfollow} title="Un-subscribe from this channel's updates, by un-following it">
Unfollow
<r4-icon name="unfollow"></r4-icon>
</button>
`
}
renderFollow() {
return html`
<button @click=${this.follow} ?disabled=${!this.userChannel} title="Subscribe to this channel's updates, by following it">Follow</button>
<button
@click=${this.follow}
?disabled=${!this.userChannel}
title="Subscribe to this channel's updates, by following it"
>
<r4-icon name="follow"></r4-icon>
</button>
`
}

Expand Down
24 changes: 8 additions & 16 deletions src/components/r4-icon.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,23 +8,8 @@ export default class R4Icon extends HTMLElement {
get icon() {
return ICONS[this.name] || ''
}
attributeChangedCallback() {
this.render()
this.renderAttr()
}
connectedCallback() {
this.render()
}
render() {
this.innerHTML = ''
this.innerText = this.icon
}
renderAttr() {
if (this.name) {
this.setAttribute('title', `${this.name} icon`)
} else {
this.removeAttribute('title')
}
this.replaceChildren(this.icon)
}
}

Expand All @@ -35,4 +20,11 @@ const ICONS = {
globe: '🌍',
dark: '🌘',
light: '🌖',
player_status: '♫',
player_close: 'x',
player_dock: '⌃',
player_minimize: '⌄',
player_fullscreen: '⌆',
follow: '☆',
unfollow: '★',
}
20 changes: 7 additions & 13 deletions src/components/r4-layout.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import {html, LitElement} from 'lit'
import {ref, createRef} from 'lit/directives/ref.js'
import {UI_STATES} from '../libs/appearence.js'

export default class R4Layout extends LitElement {
static properties = {
Expand All @@ -14,18 +15,7 @@ export default class R4Layout extends LitElement {

constructor() {
super()
this.uiStates = {
Close: 'close',
Dock: 'dock',
Minimize: 'minimize',
Fullscreen: 'fullscreen',
}
this.uiStatesUnicodes = {
[this.uiStates.Close]: 'x',
[this.uiStates.Dock]: '⌃',
[this.uiStates.Minimize]: '⌄',
[this.uiStates.Fullscreen]: '⌆',
}
this.uiStates = UI_STATES
this.uiState = this.uiStates.Minimize
document.addEventListener('fullscreenchange', this.onFullscreen.bind(this))

Expand Down Expand Up @@ -125,18 +115,22 @@ export default class R4Layout extends LitElement {
return html`
<details open part="playback-details" ${ref(this.detailsRef)}>
<summary part="playback-summary">
${this.isPlaying ? this.renderPlaybackIcon() : null}
<slot name="playback-controls"> ${Object.entries(this.uiStates).map(this.renderUiState.bind(this))} </slot>
</summary>
<slot name="player"></slot>
</details>
`
}
renderPlaybackIcon() {
return html`<r4-icon name="player_status" part="playback-status"></r4-icon>`
}

renderUiState(uiState) {
const [value, name] = uiState
return html`
<button @click=${this.onControlClick} value=${value} title=${name} name=${name} part="controls-button">
${this.uiStatesUnicodes[name]}
<r4-icon name="player_${name}"></r4-icon>
</button>
`
}
Expand Down
8 changes: 8 additions & 0 deletions src/index.css
Original file line number Diff line number Diff line change
Expand Up @@ -128,6 +128,7 @@ r4-app summary,
r4-app button,
r4-app r4-layout::part(controls-button) {
cursor: pointer;
margin: calc(var(--s) / 10);
}

r4-app progress[is='r4-loading'] {
Expand Down Expand Up @@ -218,6 +219,13 @@ r4-layout r4-player radio4000-player .Layout {
border-color: var(--c-link);
}

r4-layout::part(playback-status) {
display: flex;
flex-grow: 1;
align-self: center;
padding: calc(var(--s) / 3);
opacity: 0.3;
}
/* hide the player summary when fullscreen */
r4-layout[ui-state='fullscreen']::part(playback-summary) {
display: none;
Expand Down
10 changes: 8 additions & 2 deletions src/libs/appearence.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,11 @@
const prefersDark = window.matchMedia('(prefers-color-scheme: dark)').matches
const THEMES = ['classic', 'jellybeans', 'minimal', 'hash']
const COLOR_SCHEMES = ['os', 'light', 'dark']
const prefersDark = window.matchMedia('(prefers-color-scheme: dark)').matches
const UI_STATES = {
Close: 'close',
Dock: 'dock',
Minimize: 'minimize',
Fullscreen: 'fullscreen',
}

export {THEMES, COLOR_SCHEMES, prefersDark}
export {UI_STATES, THEMES, COLOR_SCHEMES, prefersDark}

0 comments on commit bf5711c

Please sign in to comment.