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
<!DOCTYPE html> | |
<html> | |
<head> | |
<style> | |
body { | |
display: flex; | |
flex-direction: column; | |
justify-content: center; | |
align-items: center; | |
} |
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
import React from 'react'; | |
import { CancelToken } from 'axios' | |
const FileUpload = () => { | |
const [fileList, setFileList] = useState([]) // List of File instance | |
const [sizeAmount, setSizeAmount] = useState('') // sum files size (such as '444.44 MB' or '2.15 GB') | |
const [uploadedSize, setUploadedSize] = useState('') // sum uploaded (such as '444.44 MB' or '2.15 GB') | |
const [fileCount, setFileCount] = useState(0) | |
const [progress, setProgress] = useState(0) // sum uploaded (percent) | |
const [prevLoaded, setPrevLoaded] = useState(0) // previous progressEvent.loaded |
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
import { useState, useEffect, useCallback } from 'react' | |
export default (asyncFunction, immediate = true) => { | |
const [isLoading, setIsLoading] = useState(false) | |
const [value, setValue] = useState(null) | |
const [error, setError] = useState(null) | |
const execute = useCallback( | |
async (params = {}, config = {}) => { | |
setIsLoading(true) |
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
import axios from 'axios' | |
export default axios.create({ | |
baseURL: 'http://localhost:3002', | |
headers: { 'Content-Type': 'application/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
import axios from './Axios' | |
export const uploadFiles = async (params = {}, config = {}) => { | |
return await axios.post('/upload', params, config) | |
} |
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
{ | |
/* ตัด code บางส่วนออก เพื่อความกระชับ */ | |
"scripts": { | |
"start": "craco start", | |
"build": "craco build", | |
"test": "craco test", | |
"eject": "react-scripts eject" | |
}, | |
/* ตัด code บางส่วนออก เพื่อความกระชับ */ | |
} |
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
const tailwind = require('tailwindcss') | |
const postcss = require('autoprefixer') | |
module.exports = { | |
style: { | |
postcss: { | |
plugins: [tailwind(), postcss()] | |
} | |
} | |
} |
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
module.exports = { | |
purge: ['./src/**/*.{js,jsx,ts,tsx}', './public/index.html'], | |
darkMode: 'class', | |
theme: { | |
extend: { | |
colors: { | |
dark: { | |
elem: '#2B3945', | |
bg: '#202C37', | |
text: '#FFFFFF' |
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
import React, { useState, useEffect } from 'react' | |
function getInitialTheme(): string { | |
if (typeof window !== 'undefined' && window.localStorage) { | |
const storedPrefs = window.localStorage.getItem('theme') | |
if (typeof storedPrefs === 'string') { | |
return storedPrefs | |
} | |
const userMedia = window.matchMedia('(prefers-color-scheme: dark)') |
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
import React, { useContext } from 'react'; | |
import './App.css'; | |
import { ThemeContext } from './ThemeProvider'; | |
function App() { | |
const { theme, setTheme } = useContext(ThemeContext) | |
const isDark = theme === 'dark' | |
return ( | |
<div className="bg-light-bg dark:bg-dark-bg text-light-text dark:text-dark-text h-screen flex flex-col justify-center items-center"> |
OlderNewer