Skip to content

Commit

Permalink
Merge pull request #20 from line/LIFFP-5075
Browse files Browse the repository at this point in the history
UI improvement + change UI filtering
  • Loading branch information
sugarshin authored Mar 14, 2023
2 parents bdba06e + 329c69d commit c0efc43
Show file tree
Hide file tree
Showing 7 changed files with 17 additions and 105 deletions.
10 changes: 8 additions & 2 deletions src/App.module.css
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,13 @@ body {
margin: 40px 0;
width: 400px;
display: flex;
flex-direction: row;
flex-direction: column;
gap: 16px;
}

.qrCode {
max-width: 128px;
height: auto;
}

@media only screen and (max-width: 375px) {
Expand All @@ -25,7 +31,7 @@ body {

@media only screen and (max-width: 480px) {
.liffIdBox {
width: 250px;
width: auto;
display: block;
}
}
Expand Down
24 changes: 7 additions & 17 deletions src/App.tsx
Original file line number Diff line number Diff line change
@@ -1,20 +1,16 @@
import React, { useState } from 'react'
import React from 'react'
import liff from '@line/liff'
import styles from './App.module.css'
import Header from './components/Header'
import Snippet from './components/Snippet'
import Input from './components/Input'
import Select from './components/Select'
import { FilterContext, FilterTypes, FilterType } from './Context'
import { FilterContext, FilterTypes } from './Context'
import qrCode from './qr-code.png'

const getFilterOptions = () => {
return Object.entries(FilterTypes).map(([value, label]) => ({
label, value
}))
}
const isMINI = new URLSearchParams(location.search).has('mini')
const filter = isMINI ? FilterTypes.MINI : FilterTypes.LIFF

function App() {
const [filter, setFilter] = useState<FilterType>(FilterTypes.ALL)
let isLoggedIn = false
try {
isLoggedIn = liff.isLoggedIn()
Expand All @@ -28,15 +24,9 @@ function App() {
<div className={styles.liffIdBox}>
<Input
readonly
value={'LIFF ID: ' + import.meta.env.VITE_LIFF_ID || ''}
/>
<Select
value={filter}
options={getFilterOptions()}
handleChange={(e) => {
setFilter(e.target.value as FilterType)
}}
value={`LIFF URL: https://liff.line.me/${import.meta.env.VITE_LIFF_ID.toString()}`}
/>
<img src={qrCode} className={styles.qrCode} />
</div>
<h1>Client APIs</h1>
{!isLoggedIn ? (
Expand Down
3 changes: 1 addition & 2 deletions src/Context.tsx
Original file line number Diff line number Diff line change
@@ -1,11 +1,10 @@
import React from 'react'

export const FilterTypes = {
ALL: 'ALL',
LIFF: 'LIFF',
MINI: 'MINI'
} as const

export type FilterType = keyof typeof FilterTypes

export const FilterContext = React.createContext<FilterType>(FilterTypes.ALL)
export const FilterContext = React.createContext<FilterType>(FilterTypes.LIFF)
58 changes: 0 additions & 58 deletions src/components/Select.module.css

This file was deleted.

23 changes: 0 additions & 23 deletions src/components/Select.tsx

This file was deleted.

4 changes: 1 addition & 3 deletions src/components/Snippet.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -73,9 +73,7 @@ export default function Snippet({
<FilterContext.Consumer>
{
(filter) =>
(filter === FilterTypes.ALL
|| (filter === FilterTypes.LIFF && isInLIFF)
|| (filter === FilterTypes.MINI && isInMINI))
((filter === FilterTypes.LIFF && isInLIFF) || (filter === FilterTypes.MINI && isInMINI))
&& <div className={styles.snippet}>
<div className={styles.head}>
<h2 className={styles.title}>
Expand Down
Binary file added src/qr-code.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

1 comment on commit c0efc43

@github-actions
Copy link

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.