Skip to content

Commit

Permalink
Apply formatting by biome
Browse files Browse the repository at this point in the history
  • Loading branch information
starsep committed Dec 27, 2023
1 parent 242fdcb commit b9d6ff8
Show file tree
Hide file tree
Showing 49 changed files with 3,289 additions and 2,797 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/ci_test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ jobs:
run: npm ci
- name: Run TypeScript typecheck
run: npm run typecheck
- name: Run linter
run: npm run lint
- name: Run linter & formatter
run: npm run check
- name: Build
run: npm run build
2 changes: 2 additions & 0 deletions .github/workflows/deploy_development.yml
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,8 @@ jobs:
cache: 'npm'
- name: Install dependencies
run: npm ci
- name: Run linter & formatter
run: npm run check
- name: Run TypeScript typecheck
run: npm run typecheck
- name: Set git commit
Expand Down
2 changes: 2 additions & 0 deletions .github/workflows/deploy_production.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,8 @@ jobs:
cache: 'npm'
- name: Install dependencies
run: npm ci
- name: Run linter & formatter
run: npm run check
- name: Run TypeScript typecheck
run: npm run typecheck
- name: Set git commit
Expand Down
11 changes: 10 additions & 1 deletion biome.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,15 @@
{
"$schema": "./node_modules/@biomejs/biome/configuration_schema.json",
"files": {
"ignore": [".devcontainer", "build"]
"ignore": [".devcontainer", "build", "public/locales", "public/img"]
},
"organizeImports": {
"enabled": true
},
"linter": {
"enabled": true,
"rules": {
"recommended": true
}
}
}
2 changes: 2 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,8 @@
"sprites": "spritezero ./public/img/sprite ./src/marker_icons; spritezero --ratio=2 ./public/img/sprite@2x ./src/marker_icons; spritezero --ratio=4 ./public/img/sprite@4x ./src/marker_icons",
"lint": "biome lint .",
"lint-fix": "biome lint . --apply",
"format": "biome format . --write",
"check": "biome ci .",
"css-build": "sass sass/mystyles.scss src/mystyles.css",
"css-watch": "npm run css-build -- --watch"
},
Expand Down
117 changes: 59 additions & 58 deletions public/manifest.json
Original file line number Diff line number Diff line change
@@ -1,60 +1,61 @@
{
"short_name": "OpenAEDMap",
"name": "Open AED Map",
"icons": [
{
"src": "favicon.ico",
"sizes": "64x64 32x32 24x24 16x16",
"type": "image/x-icon"
},
{
"src": "img/logo-aed-120.png",
"type": "image/png",
"sizes": "120x120"
},
{
"src": "img/logo-aed-144.png",
"type": "image/png",
"sizes": "144x144"
},
{
"src": "img/logo-aed-152.png",
"type": "image/png",
"sizes": "152x152"
},
{
"src": "img/logo-aed-180.png",
"type": "image/png",
"sizes": "180x180"
},
{
"src": "img/logo-aed-192.png",
"type": "image/png",
"sizes": "192x192"
},
{
"src": "img/logo-aed-384.png",
"type": "image/png",
"sizes": "384x384"
},
{
"src": "img/logo-aed-512.png",
"type": "image/png",
"sizes": "512x512"
}
],
"start_url": ".",
"display": "standalone",
"theme_color": "#000000",
"background_color": "#ffffff",
"related_applications": [
{
"platform": "play",
"url": "https://play.google.com/store/apps/details?id=pl.enteam.aed_map",
"id": "pl.enteam.aed_map"
}, {
"platform": "itunes",
"url": "https://apps.apple.com/app/mapa-aed/id1638495701"
}
]
"short_name": "OpenAEDMap",
"name": "Open AED Map",
"icons": [
{
"src": "favicon.ico",
"sizes": "64x64 32x32 24x24 16x16",
"type": "image/x-icon"
},
{
"src": "img/logo-aed-120.png",
"type": "image/png",
"sizes": "120x120"
},
{
"src": "img/logo-aed-144.png",
"type": "image/png",
"sizes": "144x144"
},
{
"src": "img/logo-aed-152.png",
"type": "image/png",
"sizes": "152x152"
},
{
"src": "img/logo-aed-180.png",
"type": "image/png",
"sizes": "180x180"
},
{
"src": "img/logo-aed-192.png",
"type": "image/png",
"sizes": "192x192"
},
{
"src": "img/logo-aed-384.png",
"type": "image/png",
"sizes": "384x384"
},
{
"src": "img/logo-aed-512.png",
"type": "image/png",
"sizes": "512x512"
}
],
"start_url": ".",
"display": "standalone",
"theme_color": "#000000",
"background_color": "#ffffff",
"related_applications": [
{
"platform": "play",
"url": "https://play.google.com/store/apps/details?id=pl.enteam.aed_map",
"id": "pl.enteam.aed_map"
},
{
"platform": "itunes",
"url": "https://apps.apple.com/app/mapa-aed/id1638495701"
}
]
}
189 changes: 106 additions & 83 deletions src/3rdparty/react-store-badges/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,110 +4,133 @@ import React, { FC, useLayoutEffect, useState } from "react";

const HEIGHT_RATIO = 3.375;
const getImage = (locale: string, language: string) => ({
ios: `https://apple-resources.s3.amazonaws.com/media-badges/download-on-the-app-store/black/${locale}.svg`,
android:
`https://raw.githubusercontent.com/yjb94/google-play-badge-svg/master/img/${language}_get.svg?sanitize=true`,
ios: `https://apple-resources.s3.amazonaws.com/media-badges/download-on-the-app-store/black/${locale}.svg`,
android: `https://raw.githubusercontent.com/yjb94/google-play-badge-svg/master/img/${language}_get.svg?sanitize=true`,
});

export interface ReactStoreBadgesProps {
/** url of App Store and Play Store */
url: string
/** url of App Store and Play Store */
url: string;

/** platform name. 'ios' and 'android' only */
platform: "ios" | "android"
/** platform name. 'ios' and 'android' only */
platform: "ios" | "android";

/** language name. such as en */
language: string
/** language name. such as en */
language: string;

/** width for badge size */
width?: number
/** width for badge size */
width?: number;

/** height for badge size */
height?: number
/** height for badge size */
height?: number;

/** target for url to be opened */
target?: "_self" | "_blank" | "_parent" | "_top"
/** target for url to be opened */
target?: "_self" | "_blank" | "_parent" | "_top";
}

const defaultLocale = "en-us";

function shortCodeFromLanguage(language: string): string {
switch (language) {
case "uk": return "ua";
case "zh-Hans": return "zh-cn";
case "zh-Hant": return "zh-tw";
default: return "en";
}
switch (language) {
case "uk":
return "ua";
case "zh-Hans":
return "zh-cn";
case "zh-Hant":
return "zh-tw";
default:
return "en";
}
}

function localeFromLanguage(language: string): string {
// available badges for App Store
// https://developer.apple.com/app-store/marketing/guidelines/
switch (language) {
case "ca": return "ca-es";
case "cs": return "cs-cz";
case "de": return "de-de";
case "en": return "en-us";
case "es": return "es-es";
case "fi": return "fi-fi";
case "fr": return "fr-fr";
case "it": return "it-it";
case "ja": return "ja-jp";
case "ko": return "ko-kr";
case "nl": return "nl-nl";
case "pl": return "pl-pl";
case "ru": return "ru-ru";
case "sk": return "sk-sk";
case "sl": return "sl-sl";
case "sr": return "sr-cs";
case "uk": return "uk-ua";
case "zh-Hans": return "zh-cn";
case "zh-Hant": return "zh-tw";
default: return defaultLocale;
}
// available badges for App Store
// https://developer.apple.com/app-store/marketing/guidelines/
switch (language) {
case "ca":
return "ca-es";
case "cs":
return "cs-cz";
case "de":
return "de-de";
case "en":
return "en-us";
case "es":
return "es-es";
case "fi":
return "fi-fi";
case "fr":
return "fr-fr";
case "it":
return "it-it";
case "ja":
return "ja-jp";
case "ko":
return "ko-kr";
case "nl":
return "nl-nl";
case "pl":
return "pl-pl";
case "ru":
return "ru-ru";
case "sk":
return "sk-sk";
case "sl":
return "sl-sl";
case "sr":
return "sr-cs";
case "uk":
return "uk-ua";
case "zh-Hans":
return "zh-cn";
case "zh-Hant":
return "zh-tw";
default:
return defaultLocale;
}
}

const ReactStoreBadges: FC<ReactStoreBadgesProps> = ({
url,
platform,
language,
width = 100,
height = width / HEIGHT_RATIO,
target = "_self",
url,
platform,
language,
width = 100,
height = width / HEIGHT_RATIO,
target = "_self",
}) => {
const shortCode = shortCodeFromLanguage(language);
const locale = localeFromLanguage(language);
const [image, setImage] = useState(getImage(locale, shortCode));
const shortCode = shortCodeFromLanguage(language);
const locale = localeFromLanguage(language);
const [image, setImage] = useState(getImage(locale, shortCode));

const setDefaultImage = () => {
setImage(getImage(defaultLocale, language));
};
const setDefaultImage = () => {
setImage(getImage(defaultLocale, language));
};

useLayoutEffect(() => {
setImage(getImage(locale, shortCode));
}, [locale, shortCode]);
useLayoutEffect(() => {
setImage(getImage(locale, shortCode));
}, [locale, shortCode]);

return (
<a
style={{
display: "inline-block",
height,
width,
}}
href={url}
target={target}
aria-label="Badge"
>
<img
alt=""
src={image[platform]}
style={{
width: "100%",
height: "100%",
}}
onError={setDefaultImage}
/>
</a>
);
return (
<a
style={{
display: "inline-block",
height,
width,
}}
href={url}
target={target}
aria-label="Badge"
>
<img
alt=""
src={image[platform]}
style={{
width: "100%",
height: "100%",
}}
onError={setDefaultImage}
/>
</a>
);
};
export default ReactStoreBadges;
export default ReactStoreBadges;
Loading

0 comments on commit b9d6ff8

Please sign in to comment.