Skip to content

Commit

Permalink
improve user channel select
Browse files Browse the repository at this point in the history
  • Loading branch information
ug.rp committed May 16, 2024
1 parent 29f968e commit 30232f3
Show file tree
Hide file tree
Showing 5 changed files with 33 additions and 17 deletions.
25 changes: 16 additions & 9 deletions src/components/r4-app-user-menu.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,13 @@ export default class R4AppUserMenu extends LitElement {
return this
}
static properties = {
/* props */
href: {type: String},
channel: {type: Object || null},
channels: {type: Array || null},

/* state */
path: {type: String, state: true},
}
constructor() {
super()
Expand All @@ -34,28 +38,31 @@ export default class R4AppUserMenu extends LitElement {
}

render() {
console.log('channels', this.channels, this.channel)
const {href, path} = this
return html`
<menu>
<li>${this.renderChannel()}</li>
<li>${this.channel ? this.renderAdd() : null}</li>
<li>${this.renderChannelLinks()}</li>
<li>${this.channels ? this.renderChannelSelect() : null}</li>
</menu>
`
}
renderChannel() {
renderChannelLinks() {
if (this.channel) {
return html`<a aria-current=${this.isCurrent(`/${this.channel.slug}`)} href=${this.href + '/' + this.channel.slug}
>@${this.channel.slug}</a
>`
} else {
return html`<a aria-current=${this.isCurrent('/new')} href=${this.href + '/new'}>New radio</a>`
}
}
renderChannelSelect() {
if (this.channels) {
return html`<r4-user-channels-select
.channels=${this.channels}
.channel=${this.channel}
@select=${this.onChannelSelect}
></r4-user-channels-select>`
} else if (this.channel) {
return html`<a aria-current=${this.isCurrent(`/${this.channel.slug}`)} href=${this.href + '/' + this.channel.slug}
>@${this.channel.slug}</a
>`
} else {
return html`<a aria-current=${this.isCurrent('/new')} href=${this.href + '/new'}>New radio</a>`
}
}
renderAdd() {
Expand Down
9 changes: 6 additions & 3 deletions src/components/r4-app.js
Original file line number Diff line number Diff line change
Expand Up @@ -234,9 +234,12 @@ export default class R4App extends LitElement {

onChannelSelect({detail: channel}) {
if (channel) {
const {slug} = channel
this.selectedSlug = slug
/* page(`/${this.selectedSlug}`) */
if (this.selectedSlug === channel.slug) {
/* page(`/${this.selectedSlug}`) */
} else {
this.selectedSlug = channel.slug
this.refreshUserData()
}
}
}

Expand Down
2 changes: 1 addition & 1 deletion src/components/r4-user-channels-select.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ export default class R4UserChannelsSelect extends LitElement {
<label>
<select @change=${this.onSelect} title="Selected Radio">
<optgroup label="Selected">
<option>${this.channel.slug}</option>
<option value=${this.channel.id}>${this.channel.slug}</option>
</optgroup>
<optgroup label="Channels">${this._renderOptions()}</optgroup>
</select>
Expand Down
4 changes: 4 additions & 0 deletions src/index.css
Original file line number Diff line number Diff line change
Expand Up @@ -664,6 +664,10 @@ r4-app r4-app-menu r4-title::after {
content: '.v2';
}

r4-app r4-app-user-menu menu {
flex-wrap: nowrap;
}

/* icon done in css and unicode ascii only */
r4-icon[icon]::before {
content: attr(icon);
Expand Down
10 changes: 6 additions & 4 deletions src/pages/r4-page-home.js
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,11 @@ export default class R4PageHome extends R4Page {

renderSignIn() {
return html`
<p><a href="${this.config.href}/sign/in">Sign in to your existing account</a> or <a href="${this.config.href}/sign/up">register a new account</a> to create, import or manage a Radio4000 channel.</p>
<p>
<a href="${this.config.href}/sign/in">Sign in to your existing account</a> or
<a href="${this.config.href}/sign/up">register a new account</a> to create, import or manage a Radio4000
channel.
</p>
${this.featuredChannels?.length ? this.renderFeaturedChannels() : nothing}
${this.latestTracks?.length ? this.renderTracks() : nothing}
`
Expand Down Expand Up @@ -132,9 +136,7 @@ export default class R4PageHome extends R4Page {
<p>
Welcome to the new <strong><r4-title></r4-title></strong>, version 2 (<strong>v2</strong>).
</p>
<p>
To import a radio channel from v1 to v2, <a href="${this.config.hrefMigrate}">migrate</a>.
</p>
<p>To import a radio channel from v1 to v2, <a href="${this.config.hrefMigrate}">migrate</a>.</p>
<p>
All previous radio channels are still available on the
<a href="${this.config.hrefV1}">v1</a> website.
Expand Down

0 comments on commit 30232f3

Please sign in to comment.