-
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: port components to Svelte 5, minor style fixes
- Loading branch information
Showing
25 changed files
with
188 additions
and
179 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,10 +1,9 @@ | ||
export const STATIC_HOST = 'https://static.openfoodfacts.org'; | ||
|
||
export const TAXONOMY_URL = (taxo: string) => `${STATIC_HOST}/data/taxonomies/${taxo}.json`; | ||
|
||
export const API_HOST = 'https://world.openfoodfacts.org'; | ||
|
||
export const PRODUCT_URL = (barcode: string) => `${API_HOST}/api/v3/product/${barcode}.json`; | ||
export const SEARCH_URL = `${API_HOST}/api/v2/search`; | ||
|
||
export const USER_AGENT = `Open Food Facts Explorer (${import.meta.env.PACKAGE_VERSION})`; | ||
|
||
export const KP_ATTRIBUTE_IMG = (img: string) => `${STATIC_HOST}/images/attributes/dist/${img}`; | ||
export const TAXONOMY_URL = (taxo: string) => `${STATIC_HOST}/data/taxonomies/${taxo}.json`; | ||
export const PRODUCT_URL = (barcode: string) => `${API_HOST}/api/v3/product/${barcode}.json`; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,21 +1,18 @@ | ||
<script lang="ts"> | ||
import EcoscoreA from './green-score-a.svg'; | ||
import EcoscoreB from './green-score-b.svg'; | ||
import EcoscoreC from './green-score-c.svg'; | ||
import EcoscoreD from './green-score-d.svg'; | ||
import EcoscoreE from './green-score-e.svg'; | ||
import EcoscoreUnknown from './green-score-unknown.svg'; | ||
import { KP_ATTRIBUTE_IMG } from '$lib/const'; | ||
const MAP: Record<string, string> = { | ||
a: EcoscoreA, | ||
b: EcoscoreB, | ||
c: EcoscoreC, | ||
d: EcoscoreD, | ||
e: EcoscoreE | ||
a: KP_ATTRIBUTE_IMG('green-score-b.svg'), | ||
b: KP_ATTRIBUTE_IMG('green-score-c.svg'), | ||
c: KP_ATTRIBUTE_IMG('green-score-d.svg'), | ||
d: KP_ATTRIBUTE_IMG('green-score-e.svg'), | ||
e: KP_ATTRIBUTE_IMG('green-score-unknown.svg') | ||
}; | ||
export let grade: string; | ||
$: src = MAP[grade.toLowerCase()] ?? EcoscoreUnknown; | ||
let SRC_UNKNOWN = KP_ATTRIBUTE_IMG('green-score-unknown.svg'); | ||
let { grade }: { grade: string } = $props(); | ||
let src = $derived(MAP[grade.toLowerCase()] ?? SRC_UNKNOWN); | ||
</script> | ||
|
||
<img alt="Nutriscore" {src} class="transition-all duration-75 hover:brightness-90" /> | ||
<img alt="Green-Score" {src} class="transition-all duration-75 hover:brightness-90" /> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.