Skip to content

Commit

Permalink
Refactor CSS and add JSON rendering link in header component
Browse files Browse the repository at this point in the history
  • Loading branch information
ewilan-riviere committed Oct 4, 2024
1 parent d2deb59 commit 8ac789c
Show file tree
Hide file tree
Showing 3 changed files with 30 additions and 4 deletions.
17 changes: 14 additions & 3 deletions src/components/feed.css
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,6 @@ header {

.rss {
position: fixed;
z-index: 10;
top: 0;
left: 0;
padding: 0.3rem;
Expand All @@ -42,11 +41,23 @@ header {
border-bottom-right-radius: 0.375rem;
}

.rss:hover {
.json {
position: fixed;
top: 0;
right: 0;
padding: 0.3rem;
background-color: rgba(0, 0, 0, 0.5);
z-index: 20;
border-bottom-left-radius: 0.375rem;
}

.rss:hover,
.json:hover {
background-color: rgba(0, 0, 0, 0.75);
}

.rss svg {
.rss svg,
.json svg {
fill: white;
height: 1.5rem;
width: 1.5rem;
Expand Down
12 changes: 12 additions & 0 deletions src/components/header.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,18 @@ export default {
]),
]),
]),
h('div', { class: 'json' }, [
h('a', { href: props.podcast?.jsonFormatUrl, target: '_blank', rel: 'noopener noreferrer', title: 'To JSON' }, [
h('svg', { xmlns: 'http://www.w3.org/2000/svg', viewBox: '0 0 24 24' }, [
h('g', {}, [
h('path', {
fill: 'white',
d: 'M5 3h2v2H5v5a2 2 0 0 1-2 2a2 2 0 0 1 2 2v5h2v2H5c-1.07-.27-2-.9-2-2v-4a2 2 0 0 0-2-2H0v-2h1a2 2 0 0 0 2-2V5a2 2 0 0 1 2-2m14 0a2 2 0 0 1 2 2v4a2 2 0 0 0 2 2h1v2h-1a2 2 0 0 0-2 2v4a2 2 0 0 1-2 2h-2v-2h2v-5a2 2 0 0 1 2-2a2 2 0 0 1-2-2V5h-2V3zm-7 12a1 1 0 0 1 1 1a1 1 0 0 1-1 1a1 1 0 0 1-1-1a1 1 0 0 1 1-1m-4 0a1 1 0 0 1 1 1a1 1 0 0 1-1 1a1 1 0 0 1-1-1a1 1 0 0 1 1-1m8 0a1 1 0 0 1 1 1a1 1 0 0 1-1 1a1 1 0 0 1-1-1a1 1 0 0 1 1-1',
}),
]),
]),
]),
]),
h('div', { class: 'header-block' }, [
h('div', { class: 'header-block__img' }, [
h('img', { src: props.podcast?.image, alt: props.podcast?.title, loading: 'lazy' }),
Expand Down
5 changes: 4 additions & 1 deletion src/models/Podcast.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import type { Channel } from '@/types'

Check failure on line 1 in src/models/Podcast.ts

View workflow job for this annotation

GitHub Actions / prefer-stable - ubuntu-latest

tests/feeds.test.ts

Error: Cannot find module '@/components' imported from '/home/runner/work/feedrender/feedrender/src/models/Podcast.ts'. - If you rely on tsconfig.json's "paths" to resolve modules, please install "vite-tsconfig-paths" plugin to handle module resolution. - Make sure you don't have relative aliases in your Vitest config. Use absolute paths instead. Read more: https://vitest.dev/guide/common-errors ❯ src/models/Podcast.ts:1:1 ⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯ Serialized Error: { code: 'ERR_MODULE_NOT_FOUND' }

Check failure on line 1 in src/models/Podcast.ts

View workflow job for this annotation

GitHub Actions / prefer-stable - ubuntu-latest

tests/feeds.test.ts

Error: Cannot find module '@/components' imported from '/home/runner/work/feedrender/feedrender/src/models/Podcast.ts'. - If you rely on tsconfig.json's "paths" to resolve modules, please install "vite-tsconfig-paths" plugin to handle module resolution. - Make sure you don't have relative aliases in your Vitest config. Use absolute paths instead. Read more: https://vitest.dev/guide/common-errors ❯ src/models/Podcast.ts:1:1 ⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯ Serialized Error: { code: 'ERR_MODULE_NOT_FOUND' }
import { format } from 'node:path'
import { renderDom } from '@/components'
import { Episode } from '@/models/Episode'
import { route } from '@/routes/router'
Expand All @@ -8,6 +9,7 @@ export class Podcast {
protected constructor(
public feedUrl: string,
public xmlRenderUrl: string,
public jsonFormatUrl: string,
public title?: string,
public description?: string,
public image?: string,
Expand Down Expand Up @@ -36,7 +38,8 @@ export class Podcast {
public static make(feedUrl: string, channel: Channel, lang: string = 'en'): Podcast {
// http://localhost:3000/api/xml?url=http://zqsd.fr/zqsd.xml
const xmlRenderUrl = route('/api/xml', { query: { url: feedUrl } })
const self = new this(feedUrl, xmlRenderUrl)
const jsonFormatUrl = route('/api/render', { query: { url: feedUrl, format: 'json' } })
const self = new this(feedUrl, xmlRenderUrl, jsonFormatUrl)

self.title = channel.title

Expand Down

0 comments on commit 8ac789c

Please sign in to comment.