Skip to content

Commit

Permalink
🔖 v1.2.0
Browse files Browse the repository at this point in the history
  • Loading branch information
xnousnow committed May 13, 2023
2 parents d2f0007 + 7ddc495 commit 6728522
Show file tree
Hide file tree
Showing 9 changed files with 132 additions and 9 deletions.
4 changes: 2 additions & 2 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "todayschoolmeal",
"version": "1.1.0",
"version": "1.2.0",
"private": true,
"scripts": {
"dev": "vite dev --host",
Expand Down
2 changes: 2 additions & 0 deletions src/components/MealList.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
import { onMount } from 'svelte'
import { selectedCity, selectedSchool } from '../stores'
import { settings } from '../settings'
import { School2, AlertCircle, ClipboardX } from 'lucide-svelte'
import SimpleInfo from './SimpleInfo.svelte'
Expand Down Expand Up @@ -54,6 +55,7 @@
}
async function canBeStarred(menu: MenuToken[]): Promise<number> {
if (!$settings.viewMenuSurvey) return 0
let name = menu.map((token) => token.string).join('')
const { data } = await supabase
.from('menus')
Expand Down
12 changes: 11 additions & 1 deletion src/components/MenuBar.svelte
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
<script lang="ts">
import { ChevronLeft, Search } from 'lucide-svelte'
export let title: string,
export let LeftButton: any = null,
leftButtonLink: string = '',
title: string,
buttons: any[] = [],
buttonLinks: (string | undefined)[] = [],
primary: boolean = false,
Expand All @@ -28,6 +30,14 @@
>
<ChevronLeft class="h-7 w-7" />
</button>
{:else if LeftButton}
<a
href={leftButtonLink}
class="mr-3 rounded hover:bg-black/5 active:bg-black/10 p-1"
role="button"
>
<LeftButton class="h-7 w-7" />
</a>
{/if}
<h1 class="text-[20px] font-semibold">{title}</h1>
{#if buttons.length}
Expand Down
17 changes: 15 additions & 2 deletions src/fetchMeal.ts
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,11 @@ export function removeAllergyInfo(meal: string[]) {
return meal.map((menu) => menu.replace(/ +\([0-9. ]+\)/g, ''))
}

export async function getMeal(cityCode: string, schoolCode: number, date: string): Promise<Response> {
export async function getMeal(
cityCode: string,
schoolCode: number,
date: string
): Promise<Response> {
let meal: string[] = []
let error = false
let errorCode = 0
Expand All @@ -66,7 +70,9 @@ export async function getMeal(cityCode: string, schoolCode: number, date: string
const json = await res.json()

if (json.mealServiceDietInfo) {
meal = removeAllergyInfo(json.mealServiceDietInfo[1].row[0].DDISH_NM.split('<br/>'))
meal = removeAllergyInfo(
json.mealServiceDietInfo[1].row[0].DDISH_NM.split(/<br\/>|&/g)
).map(cleanMenu).filter(Boolean)
error = false
errorCode = 0
} else {
Expand All @@ -77,3 +83,10 @@ export async function getMeal(cityCode: string, schoolCode: number, date: string
return { body: meal, error, errorCode }
}

export function cleanMenu(menu: string): string {
// 우유
if (menu.match(/^ *(급식|강화|우유)?\(?(우유)?(급식)?\)? *$/g)) return ''
// 흰죽 (환아용)
if (menu.match(/^ *흰죽 *\(환아용\) *$/g)) return ''
return menu.replace(/[^가-힣()]/g, '')
}
9 changes: 7 additions & 2 deletions src/routes/+page.svelte
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
<script lang="ts">
import { goto } from '$app/navigation'
import { settings } from '../settings'
import { Search } from 'lucide-svelte'
import { Settings, Search } from 'lucide-svelte'
import CenteredSchool2 from '../components/CenteredSchool2.svelte'
import MenuBar from '../components/MenuBar.svelte'
Expand Down Expand Up @@ -30,6 +31,8 @@
</script>

<MenuBar
LeftButton={Settings}
leftButtonLink="/settings"
title="오늘뭐먹지"
buttons={[CenteredSchool2, Search]}
buttonLinks={['/school-selection', '/vegetable-search']}
Expand All @@ -44,4 +47,6 @@
date = newDate
}}
/>
<MenuSurvey />
{#if $settings.parcipiateMenuSurvey}
<MenuSurvey />
{/if}
65 changes: 65 additions & 0 deletions src/routes/settings/+page.svelte
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
<script lang="ts">
import { settings } from '../../settings'
import type { Settings } from '../../settings'
import MenuBar from '../../components/MenuBar.svelte'
let _settings: Settings = $settings
settings.subscribe((value) => {
_settings = value
})
$: {
settings.update((value) => {
value = _settings
return value
})
}
</script>

<MenuBar title="설정" back={true} />
<div class="flex h-full grow flex-col gap-3 bg-neutral-100 p-4">
<ul class="divide-y overflow-hidden rounded-lg">
<li>
<label
class="flex cursor-pointer items-center justify-between bg-white px-5 py-1 hover:bg-neutral-50"
>
<span class="my-2">메뉴 설문 참가</span>
<input
type="checkbox"
class="peer appearance-none"
bind:checked={_settings.parcipiateMenuSurvey}
/>
<div
class="group-9 w-14 rounded-full border-2 bg-neutral-50 transition duration-500 peer-checked:border-green-500 peer-checked:bg-green-500 peer-checked:[&>div]:translate-x-5"
>
<div class="h-8 w-8 transform rounded-full bg-white shadow transition duration-300" />
</div>
</label>
</li>
<li>
<label
class="flex cursor-pointer items-center justify-between bg-white px-5 py-1 hover:bg-neutral-50"
>
<div class="flex flex-col my-2">
<span>메뉴 설문 결과 보기</span>
<p class="text-neutral-400 text-xs">메뉴 설문에서 다른 학생들이 만족스럽다고 표시한 메뉴에 별을 표시해요.</p>
</div>
<input
type="checkbox"
class="peer appearance-none"
bind:checked={_settings.viewMenuSurvey}
/>
<div
class="group-9 w-14 rounded-full border-2 bg-neutral-50 transition duration-500 peer-checked:border-green-500 peer-checked:bg-green-500 peer-checked:[&>div]:translate-x-5"
>
<div class="h-8 w-8 transform rounded-full bg-white shadow transition duration-300" />
</div>
</label>
</li>
</ul>
<ul class="overflow-hidden rounded-lg">
<li class="bg-white px-5 py-3 text-neutral-400">v1.2.0</li>
</ul>
</div>
28 changes: 28 additions & 0 deletions src/settings.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
import { writable } from 'svelte/store'

interface Settings {
parcipiateMenuSurvey: boolean
viewMenuSurvey: boolean
}

const defaultSettings: Settings = {
parcipiateMenuSurvey: true,
viewMenuSurvey: true
}
const settings = writable<Settings>()

if (typeof window !== 'undefined') {
const savedSettings = localStorage.getItem('settings')
const mergedSettings = {...defaultSettings, ...JSON.parse(savedSettings || '{}')}
settings.set(mergedSettings)

settings.subscribe((value) => {
if (!value) return
localStorage.setItem('settings', JSON.stringify(value))
})
} else {
settings.set(defaultSettings)
}

export { settings, defaultSettings }
export type { Settings }
2 changes: 1 addition & 1 deletion src/vegetableData.ts
Original file line number Diff line number Diff line change
Expand Up @@ -360,7 +360,7 @@ const vegetableData: Array<Vegetable> = [
},
{
name: '무',
exceptions: ['열무', '무침', '율무'],
exceptions: ['열무', '무침', '율무', '단무지', '무스'],
images: [
'https://upload.wikimedia.org/wikipedia/commons/thumb/a/ab/Japanese_radish_field.jpg/640px-Japanese_radish_field.jpg',
'https://upload.wikimedia.org/wikipedia/commons/thumb/5/54/Korean_radish_%28mu%29.jpg/640px-Korean_radish_%28mu%29.jpg',
Expand Down

1 comment on commit 6728522

@vercel
Copy link

@vercel vercel bot commented on 6728522 May 13, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.