repo_name
stringlengths
5
122
path
stringlengths
3
232
text
stringlengths
6
1.05M
Krinkle/sauce-connect-action
src/wait.ts
import {watch} from 'fs' export async function wait(dir: string): Promise<unknown> { return new Promise((resolve, reject) => { const timeout = setTimeout(() => { watcher.close() reject( new Error( 'timeout: SC was not ready even after we wait 60 secs' ) ) }, 60 * 1000) const watcher = watch(dir, (eventType, filename) => { if (filename !== 'sc.ready') { return } clearTimeout(timeout) watcher.close() resolve(void 0) }) }) }
Krinkle/sauce-connect-action
src/exec-and-return.ts
import {exec} from '@actions/exec' export async function execAndReturn( commandLine: string, args?: string[] ): Promise<string> { let output = '' await exec(commandLine, args, { listeners: { stdout: (data: Buffer) => { output += data.toString() } } }) return output }
Krinkle/sauce-connect-action
src/post.ts
import {getState, warning, setFailed} from '@actions/core' import {stopContainer} from './stop-container' async function run(): Promise<void> { const containerId = getState('containerId') if (!containerId) { warning( 'No state found. Assume that no container run in this workflow run.' ) return } await stopContainer(containerId) } // eslint-disable-next-line github/no-then run().catch(error => setFailed(error.message))
Krinkle/sauce-connect-action
src/stop-container.ts
import {info} from '@actions/core' import {exec} from '@actions/exec' import {execAndReturn} from './exec-and-return' export async function stopContainer(containerId: string): Promise<void> { info(`Trying to stop the docker container with ID ${containerId}...`) const running = ( await execAndReturn('docker', [ 'ps', '-q', '-f', `id=${containerId}` ]) ).trim() !== '' if (running) { await exec('docker', ['container', 'stop', containerId]) } else { info('Container not running.') } info('Done.') }
vinayakkulkarni/vite
src/types.ts
<reponame>vinayakkulkarni/vite<filename>src/types.ts import type { InlineConfig, SSROptions } from 'vite' import type { VueViteOptions } from 'vite-plugin-vue2' export interface Nuxt { options: any; resolver: any; hook: Function; callHook: Function; } export interface ViteOptions extends InlineConfig { /** * Options for vite-plugin-vue2 * * @link https://github.com/underfin/vite-plugin-vue2 */ vue?: VueViteOptions ssr?: SSROptions } export interface ViteBuildContext { nuxt: Nuxt; builder: { plugins: { name: string; mode?: 'client' | 'server'; src: string; }[]; }; config: ViteOptions; }
vinayakkulkarni/vite
src/utils/warmup.ts
<gh_stars>0 import type { ViteDevServer } from 'vite' export async function warmupViteServer (server: ViteDevServer, entries: string[]) { const warmedUrls = new Set<String>() const warmup = async (url: string) => { if (warmedUrls.has(url)) { return undefined } warmedUrls.add(url) await server.transformRequest(url) const deps = Array.from(server.moduleGraph.urlToModuleMap.get(url).importedModules) await Promise.all(deps.map(m => warmup(m.url))) } await Promise.all(entries.map(entry => warmup(entry))) }
vinayakkulkarni/vite
src/plugins/default-export.ts
<reponame>vinayakkulkarni/vite<filename>src/plugins/default-export.ts import type { Plugin } from 'vite' import { readFile } from 'fs-extra' // const PREFIX = 'defaultexport:' const PREFIX = 'defaultexport:' const hasPrefix = (id: string = '') => id.startsWith(PREFIX) const removePrefix = (id: string = '') => hasPrefix(id) ? id.substr(PREFIX.length) : id const hasDefaultExport = (code: string = '') => code.includes('export default') const addDefaultExport = (code: string = '') => code + '\n\n' + 'export default () => {}' export function defaultExportPlugin () { return <Plugin>{ name: 'nuxt:default-export', enforce: 'pre', resolveId (id, importer) { if (hasPrefix(id)) { return id } if (importer && hasPrefix(importer)) { return this.resolve(id, removePrefix(importer)) } return null }, async load (id) { if (hasPrefix(id)) { let code = await readFile(removePrefix(id), 'utf8') if (!hasDefaultExport(code)) { code = addDefaultExport(code) } return { map: null, code } } return null } } }
vinayakkulkarni/vite
src/css.ts
import createResolver from 'postcss-import-resolver' import defu from 'defu' import type { Nuxt, ViteOptions } from './types' // Ref: https://github.com/nuxt/nuxt.js/blob/dev/packages/webpack/src/utils/postcss.js export function resolveCSSOptions (nuxt: Nuxt): ViteOptions['css'] { const css: ViteOptions['css'] = { postcss: { plugins: [] } } const plugins = defu(nuxt.options.build.postcss.plugins, { // https://github.com/postcss/postcss-import 'postcss-import': { resolve: createResolver({ alias: { ...nuxt.options.alias }, modules: [ nuxt.options.srcDir, nuxt.options.rootDir, ...nuxt.options.modulesDir ] }) }, // https://github.com/postcss/postcss-url 'postcss-url': {}, // https://github.com/csstools/postcss-preset-env 'postcss-preset-env': nuxt.options.build.postcss.preset || {} }) for (const name in plugins) { const opts = plugins[name] if (!opts) { continue } const plugin = nuxt.resolver.requireModule(name) // @ts-ignore css.postcss.plugins.push(plugin(opts)) } return css }
vinayakkulkarni/vite
src/plugins/jsx.ts
<filename>src/plugins/jsx.ts import type { Plugin } from 'vite' const needsJsxProcessing = (id: string = '') => !id.includes('node_modules') && ['.vue', '.jsx', '.tsx'].some(extension => id.includes(extension)) export function jsxPlugin () { return <Plugin>{ name: 'nuxt:jsx', transform (code, id) { if (!needsJsxProcessing(id)) { return null } return { code: code.replace(/render\s*\(\s*\)\s*\{/g, 'render(h){'), map: null } } } }
vinayakkulkarni/vite
src/plugins/replace.ts
import type { Plugin } from 'vite' export function replace (replacements: Record<string, string>) { return <Plugin>{ name: 'nuxt:replace', transform (code) { Object.entries(replacements).forEach(([key, value]) => { const escapedKey = key.replace(/\./g, '\\.') code = code.replace(new RegExp(escapedKey, 'g'), value) }) return { code, map: null } } } }
BigMoneyKirk/QR_Proto
src/app/components/main/main.component.ts
import { Component, OnInit } from '@angular/core'; import { ImageService } from 'src/app/services/image.service'; import { VCard } from "ngx-vcard"; @Component({ selector: 'app-main', templateUrl: './main.component.html', styleUrls: ['./main.component.scss'] }) export class MainComponent implements OnInit { constructor(public imageService: ImageService) { } ngOnInit() { } public vCard: VCard = { name: { firstNames: "Stephen", lastNames: "Kirkland", }, telephone: ["912-536-7419"], email: ["<EMAIL>"], workEmail: ["<EMAIL>"], role: "CEO of Kirkland Enterprises Unlimited", url: "https://BigMoneyKirk.github.io/QR/", sound: "../../assets/sounds/Stephen_Kirkland.m4a", logo: "../../assets/images/logos/KEU_Logo_FullColor.png", photo: "Li4vLi4vYXNzZXRzL2ltYWdlcy9sb2dvcy9LRVVfTG9nb19GdWxsQ29sb3IucG5n", note: "Creator of the QR Virtual Business Card" }; }
jayce-incognito/leapxpert-test-fe
src/module/Setting/features/SettingItem/SettingItem.styled.ts
import styled from 'styled-components'; export const Styled = styled.div` margin-bottom: 30px; .title { padding-bottom: 15px; } .toggle-item { display: flex; flex-direction: row; justify-content: space-between; align-items: center; } .pointer { cursor: pointer; } `;
jayce-incognito/leapxpert-test-fe
src/components/Templates/index.ts
<filename>src/components/Templates/index.ts export { default } from './Templates'; export * from './Templates.actions'; export * from './Templates.constant'; export * from './Templates.interface'; export * from './Templates.reducer'; export * from './Templates.selector'; export * from './Templates.route';
jayce-incognito/leapxpert-test-fe
src/module/Setting/features/Network/index.ts
export { default } from './Network'; export * from './Network.route';
jayce-incognito/leapxpert-test-fe
src/components/Icons/FastFee.tsx
<gh_stars>0 import React from 'react'; import styled, { css } from 'styled-components'; import { COLORS, ITheme } from 'src/styles'; interface IProps { fast2x?: boolean; handleClick: () => any; } const Lightning = styled.button<{ selectFast: any }>` width: 56px; height: 30px; border-radius: 8px; margin-left: 5px; .one-light { .border { fill: ${COLORS.black1}; stroke: ${COLORS.black1}; } .icon { fill: ${COLORS.white}; } ${(props) => props.selectFast && css` .border { fill: ${(props: { theme: ITheme }) => props.theme.fastFeeButton}; stroke: ${(props: { theme: ITheme }) => props.theme.fastFeeBorderButton}; } .icon { fill: ${(props: { theme: ITheme }) => props.theme.fastFeeTextButton}; } `} } .two-light { .border { fill: ${COLORS.black1}; stroke: ${COLORS.black1}; } .icon { fill: ${COLORS.white}; } ${(props) => !props.selectFast && css` .border { fill: ${(props: { theme: ITheme }) => props.theme.fastFeeButton}; stroke: ${(props: { theme: ITheme }) => props.theme.fastFeeBorderButton}; } .icon { fill: ${(props: { theme: ITheme }) => props.theme.fastFeeTextButton}; } `} } `; const OneLightVector = React.memo((props: any) => { return ( <svg className="one-light" width={56} height={30} {...props}> <g fill="none" fillRule="evenodd"> <path className="border" d="M11.256 1h33.488c3.567 0 4.86.371 6.163 1.069a7.27 7.27 0 013.024 3.024C54.63 6.396 55 7.689 55 11.256v7.488c0 3.567-.371 4.86-1.069 6.163a7.27 7.27 0 01-3.024 3.024C49.604 28.63 48.311 29 44.744 29H11.256c-3.567 0-4.86-.371-6.163-1.069a7.27 7.27 0 01-3.024-3.024C1.37 23.604 1 22.311 1 18.744v-7.488c0-3.567.371-4.86 1.069-6.163a7.27 7.27 0 013.024-3.024C6.396 1.37 7.689 1 11.256 1z" stroke="#CBCBCB" strokeWidth={0.5} fill="#F3F3F3" /> <path className="icon" d="M26.154 22.365l6.214-7.765c.116-.144.178-.28.178-.438 0-.26-.205-.465-.492-.465H28.19L30.23 8.16c.266-.704-.465-1.08-.923-.499l-6.214 7.759c-.116.15-.178.287-.178.437 0 .267.205.465.492.465h3.863L25.23 21.86c-.266.704.465 1.08.923.506z" fill="#8A8A8E" fillRule="nonzero" /> </g> </svg> ); }); const TwoLightVector = React.memo((props: any) => { return ( <svg className="two-light" width={56} height={30} {...props}> <g fill="none" fillRule="evenodd"> <path className="border" d="M11.256 1h33.488c3.567 0 4.86.371 6.163 1.069a7.27 7.27 0 013.024 3.024C54.63 6.396 55 7.689 55 11.256v7.488c0 3.567-.371 4.86-1.069 6.163a7.27 7.27 0 01-3.024 3.024C49.604 28.63 48.311 29 44.744 29H11.256c-3.567 0-4.86-.371-6.163-1.069a7.27 7.27 0 01-3.024-3.024C1.37 23.604 1 22.311 1 18.744v-7.488c0-3.567.371-4.86 1.069-6.163a7.27 7.27 0 013.024-3.024C6.396 1.37 7.689 1 11.256 1z" stroke="#CBCBCB" strokeWidth={0.5} fill="#F3F3F3" /> <path className="icon" d="M20.154 22.365l6.214-7.765c.116-.144.178-.28.178-.438 0-.26-.205-.465-.492-.465H22.19L24.23 8.16c.266-.704-.465-1.08-.923-.499l-6.214 7.759c-.116.15-.178.287-.178.437 0 .267.205.465.492.465h3.863L19.23 21.86c-.266.704.465 1.08.923.506zM32.034 22.365l6.214-7.765c.116-.144.178-.28.178-.438 0-.26-.205-.465-.492-.465H34.07L36.11 8.16c.266-.704-.465-1.08-.923-.499l-6.214 7.759c-.116.15-.178.287-.178.437 0 .267.205.465.492.465h3.863L31.11 21.86c-.266.704.465 1.08.923.506z" fill="#8A8A8E" fillRule="nonzero" /> </g> </svg> ); }); const FastFee = (props: IProps & React.ButtonHTMLAttributes<HTMLButtonElement>) => { const { fast2x, handleClick } = props; const renderOneLight = () => { return ( <Lightning selectFast={fast2x} onClick={() => { fast2x && handleClick(); }} type="button" {...props} > <OneLightVector /> </Lightning> ); }; const renderTwoLight = () => { return ( <Lightning selectFast={fast2x} onClick={() => { !fast2x && handleClick(); }} type="button" {...props} > <TwoLightVector /> </Lightning> ); }; return ( <div className="flex"> {renderOneLight()} {renderTwoLight()} </div> ); }; export default FastFee;
jayce-incognito/leapxpert-test-fe
src/components/Core/Tabs/Tabs.constant.ts
<reponame>jayce-incognito/leapxpert-test-fe<gh_stars>0 export const ACTION_CHANGE_TAB = `[tabs] Change active tab`;
jayce-incognito/leapxpert-test-fe
src/module/Tooltip/Tooltip.wrapper.tsx
import React, { HTMLAttributes } from 'react'; import { useDispatch } from 'react-redux'; import styled from 'styled-components'; import { actionRemoveTooltip, actionShowTooltip } from './Tooltip.actions'; const Styled = styled.div``; const TooltipWrapper = (props: { text: string; id: string } & HTMLAttributes<HTMLDivElement>) => { const { id, text, children } = props; const ref: any = React.useRef(); const dispatch = useDispatch(); const handleHover = () => { dispatch( actionShowTooltip({ id, text, ref: ref ? ref.current : null, timeout: 0, }), ); }; const handleHoverOut = () => { dispatch(actionRemoveTooltip(id)); }; return ( <Styled ref={ref} onMouseOver={handleHover} onMouseOut={handleHoverOut}> {children} </Styled> ); }; export default TooltipWrapper;
jayce-incognito/leapxpert-test-fe
src/module/Tooltip/Tooltip.enhance.tsx
<gh_stars>0 import React, { useEffect, useState } from 'react'; import { compose } from 'recompose'; import { useDispatch } from 'react-redux'; import useOutsideRef from 'src/hooks/useDetectClickOutside'; import { ITooltipProps } from './Tooltip.interface'; import { actionRemoveTooltip } from './Tooltip.actions'; /** * Get first scrollable parent * Thank to twxia (https://gist.github.com/twxia/bb20843c495a49644be6ea3804c0d775) * @param node */ function getScrollParent(node: any): HTMLElement | null | any { const isElement = node instanceof HTMLElement; const overflowY = isElement && window.getComputedStyle(node).overflowY; const isScrollable = overflowY !== 'visible' && overflowY !== 'hidden'; if (!node) { return null; } if (isScrollable && node.scrollHeight >= node.clientHeight) { return node; } if (node.parentNode) { return getScrollParent(node.parentNode); } return document.body; } const enhance = (WrappedComponent: React.FunctionComponent<ITooltipProps>) => (props: ITooltipProps) => { const [tooltipPosition, setTooltipPosition] = useState<any>({}); const { data } = props; const { id, text, timeout, ref, width, height, margin } = data; const dispatch = useDispatch(); const handleClickOutsideRef = () => { dispatch(actionRemoveTooltip(id)); }; useOutsideRef(ref, handleClickOutsideRef); useEffect(() => { if (timeout && timeout > 0) { const parentScrollView = getScrollParent(ref.offsetParent); const timeoutTimer = setTimeout(() => { dispatch(actionRemoveTooltip(id)); }, timeout * 1000); const handleRemoveTooltipOnScroll = () => { dispatch(actionRemoveTooltip(id)); clearTimeout(timeoutTimer); parentScrollView.removeEventListener('scroll', handleRemoveTooltipOnScroll); }; parentScrollView.addEventListener('scroll', handleRemoveTooltipOnScroll); return () => { parentScrollView.removeEventListener('scroll', handleRemoveTooltipOnScroll); clearTimeout(timeoutTimer); }; } }, [id]); useEffect(() => { if (text && ref && width && height) { const refRect = ref.getBoundingClientRect(); const { bottom, left, right } = refRect; const middle = (left + right) / 2; setTooltipPosition({ width, top: bottom + margin, bottom: bottom + height, left: middle - width / 2, right: middle + width / 2, }); } }, [text, ref, width, height]); return <WrappedComponent {...props} tooltipPosition={tooltipPosition} />; }; export default compose<ITooltipProps, any>(enhance);
jayce-incognito/leapxpert-test-fe
src/components/Icons/ArrowDown.tsx
import React from 'react'; import styled from 'styled-components'; interface IProps {} const Styled = styled.button` width: 18px; height: 10px; `; const ArrowDownVector = React.memo((props: any) => { return ( <svg width={16} height={10}> <path d="M7.879 9.339c.22 0 .44-.088.589-.255l6.803-6.97a.784.784 0 00.237-.562.788.788 0 00-.8-.809.835.835 0 00-.571.229L7.879 7.37 1.612.972a.803.803 0 00-.571-.229c-.457 0-.8.352-.8.809 0 .22.088.413.238.571L7.28 9.084c.167.167.37.255.598.255z" fill="#000" fillRule="nonzero" {...props} /> </svg> ); }); const ArrowDown = (props: IProps & React.ButtonHTMLAttributes<HTMLButtonElement>) => { return ( <Styled className="icon arrow-down-icon" {...props}> <ArrowDownVector /> </Styled> ); }; export default ArrowDown;
jayce-incognito/leapxpert-test-fe
src/components/Templates/Templates.tsx
<gh_stars>0 import React from 'react'; import styled from 'styled-components'; const Styled = styled.div``; const Templates = () => { return <Styled />; }; export default React.memo(Templates);
jayce-incognito/leapxpert-test-fe
src/module/Setting/features/SettingItem/index.ts
<filename>src/module/Setting/features/SettingItem/index.ts<gh_stars>0 export { default } from './SettingItem'; export * from './SettingItem.interface';
jayce-incognito/leapxpert-test-fe
src/components/ReduxForm/validator.ts
import isEmpty from 'lodash/isEmpty'; const required = (value: any) => (isEmpty(value) ? 'Required' : undefined); const maxLength = (max: number, message?: string) => (value: string) => value && value.length > max ? message || `Must be ${max} characters or less` : undefined; const minLength = (min: number, message?: string) => (value: string) => value && value.length < min ? message || `Must be ${min} characters or more` : undefined; const email = (message?: string) => (value: string) => value && !/^[A-Z0-9._%+-]+@[A-Z0-9.-]+\.[A-Z]{2,4}$/i.test(value) ? message || 'Invalid email address' : undefined; const validator = { minLength, maxLength, required, email, }; export default validator;
jayce-incognito/leapxpert-test-fe
src/components/Core/Tabs/Tabs.reducer.ts
<reponame>jayce-incognito/leapxpert-test-fe import { IAction } from 'src/redux/interface'; import { ACTION_CHANGE_TAB } from './Tabs.constant'; import { ITabsReducer } from './Tabs.interface'; const initialState: ITabsReducer = { active: '', }; const reducer = (state = initialState, action: IAction) => { switch (action.type) { case ACTION_CHANGE_TAB: { return { ...state, active: action.payload, }; } default: return state; } }; export default reducer;
jayce-incognito/leapxpert-test-fe
src/components/Header/Header.headerApp.tsx
import React from 'react'; import styled from 'styled-components'; import { AppIcon, SettingIcon } from 'src/components/Icons'; interface IProps { customLeftHeader?: any; } const Styled = styled.div` &.header { margin-bottom: 30px; } `; const Header = (props: IProps & any) => { const { customLeftHeader } = props; return ( <Styled className="header flex-jcb"> <div className="header-left flex"> <SettingIcon /> {customLeftHeader && customLeftHeader} </div> <div className="header-right"> <AppIcon /> </div> </Styled> ); }; export default Header;
jayce-incognito/leapxpert-test-fe
src/components/Core/ToggleSwitch/ToggleSwitch.tsx
import React from 'react'; import { useSelector } from 'react-redux'; import { themeSelector } from 'src/module/Setting'; import { ITheme, IGlobalStyle } from 'src/styles'; import styled from 'styled-components'; interface IProps { toggleValue?: boolean; onToggle?: () => void; } const Styled = styled.div` cursor: pointer; position: relative; display: inline-block; width: 40px; height: 21px; input { opacity: 0; width: 0; height: 0; } .slider { position: absolute; cursor: pointer; top: 0; left: 0; right: 0; bottom: 0; background-color: ${(props: IGlobalStyle) => props.theme.switchButton}; -webkit-transition: 0.4s; transition: 0.4s; } .slider:before { position: absolute; content: ''; height: 17px; width: 17px; left: 2px; bottom: 2px; background-color: white; -webkit-transition: 0.4s; transition: 0.4s; } input:checked + .slider { background-color: ${(props: IGlobalStyle) => props.theme.switchActiveButton}; } input:focus + .slider { box-shadow: 0 0 1px ${(props: IGlobalStyle) => props.theme.switchActiveButton}; } input:checked + .slider:before { transform: translateX(18px); } /* Rounded sliders */ .slider.round { border-radius: 10.5px; } .slider.round:before { border-radius: 50%; } `; const ToggleSwitch = (props: IProps) => { const theme: ITheme = useSelector(themeSelector); const { toggleValue, onToggle } = props; const handleOnClick = () => { if (typeof onToggle === 'function') { onToggle(); } }; return ( <Styled theme={theme} className="switch" onClick={handleOnClick}> <input type="checkbox" readOnly checked={!!toggleValue} /> <span className="slider round" /> </Styled> ); }; export default ToggleSwitch;
jayce-incognito/leapxpert-test-fe
src/components/Core/Tabs/Tabs.selector.ts
import { IRootState } from 'src/redux/interface'; import { createSelector } from 'reselect'; export const tabsSelector = createSelector( (state: IRootState) => state.tabs, (tabs) => tabs, ); export const activeTabSelector = createSelector(tabsSelector, (tabs) => tabs.active);
jayce-incognito/leapxpert-test-fe
src/components/Icons/Key.tsx
<gh_stars>0 import React, { useEffect, useRef } from 'react'; import styled from 'styled-components'; import { useDispatch, useSelector } from 'react-redux'; import { darkModeSelector, translateByFieldSelector } from 'src/module/Setting'; import { IGeneralLanguage } from 'src/i18n'; import { actionRemoveTooltip, actionShowTooltip } from 'src/module/Tooltip'; import { COLORS } from 'src/styles'; interface IProps {} const Styled = styled.button<{ darkMode: boolean }>` width: 37px; height: 23px; svg { .stroke { fill: ${(props) => (props?.darkMode ? COLORS.black2 : COLORS.colorGrey)}; stroke: ${(props) => (props?.darkMode ? COLORS.black1 : COLORS.colorKeyGrey)}; } } `; const KeyVector = React.memo((props: any) => { return ( <svg width={37} height={23} {...props}> <g fill="none" fillRule="evenodd"> <path d="M7.41 1h22.18c2.23 0 3.037.232 3.852.668a4.543 4.543 0 011.89 1.89c.436.815.668 1.623.668 3.852v8.18c0 2.23-.232 3.037-.668 3.852a4.543 4.543 0 01-1.89 1.89c-.815.436-1.623.668-3.852.668H7.41c-2.23 0-3.037-.232-3.852-.668a4.543 4.543 0 01-1.89-1.89C1.232 18.627 1 17.82 1 15.59V7.41c0-2.23.232-3.037.668-3.852a4.543 4.543 0 011.89-1.89C4.373 1.232 5.18 1 7.41 1z" fill="#121212" className="stroke" /> <path d="M28.418 8.474c1.959 1.959 1.951 5.127.013 7.065-1.938 1.937-5.12 1.959-7.078 0a5.001 5.001 0 01-1.27-2.16l-6.148-.01.003 1.644a.791.791 0 01-.808.808l-2.588-.005a.798.798 0 01-.81-.81l-.004-1.645h-.35A1.393 1.393 0 018 11.982a1.358 1.358 0 011.36-1.387l10.717.007a4.954 4.954 0 011.263-2.155c1.938-1.938 5.12-1.932 7.078.026zm-5.106 1.946a2.234 2.234 0 00.006 3.154c.865.892 2.28.88 3.155.006a2.234 2.234 0 00-.006-3.154 2.234 2.234 0 00-3.155-.006z" fill="#8A8A8E" /> </g> </svg> ); }); const id = 'key'; const Key = (props: IProps & React.ButtonHTMLAttributes<HTMLButtonElement>) => { const iconRef: any = useRef(); const dispatch = useDispatch(); const darkMode = useSelector(darkModeSelector); const translate: IGeneralLanguage = useSelector(translateByFieldSelector)('general'); const handleHover = () => { dispatch( actionShowTooltip({ id, text: translate.seeKey, ref: iconRef ? iconRef.current : null, timeout: 0, }), ); }; const handleHoverOut = () => { dispatch(actionRemoveTooltip(id)); }; useEffect(() => { return () => { dispatch(actionRemoveTooltip(id)); }; }); return ( <Styled darkMode={darkMode} className="icon" {...props} onMouseOver={handleHover} onMouseOut={handleHoverOut}> <span ref={iconRef}> <KeyVector /> </span> </Styled> ); }; export default Key;
jayce-incognito/leapxpert-test-fe
src/module/Setting/features/SettingItem/SettingItem.interface.ts
export interface ISettingChildItem { desc?: string; toggle?: boolean; onClick?: () => void; link?: string; toggleValue?: boolean; } export interface ISettingItem { title: string; child?: ISettingChildItem[]; button?: boolean; onClick?: () => void; }
jayce-incognito/leapxpert-test-fe
src/components/Core/Checkbox/index.tsx
import React from 'react'; import styled from 'styled-components'; import PropTypes from 'prop-types'; import { COLORS } from 'src/styles'; interface IProps { onHandleChecked: () => any; label: string; checked: boolean; } const Styled = styled.div` & { flex-direction: row; align-items: center; display: flex; margin: 15px 0; /* The container */ .container { position: relative; height: 25px; width: 25px; cursor: pointer; margin-right: 25px; user-select: none; } .container input { position: absolute; opacity: 0; cursor: pointer; height: 0; width: 0; } .checkmark { position: absolute; top: 0; left: 0; width: 100%; height: 100%; background-color: ${COLORS.black}; } .container input:checked ~ .checkmark { background-color: ${COLORS.black}; } .checkmark:after { content: ''; position: absolute; display: none; } .container input:checked ~ .checkmark:after { display: block; } .container .checkmark:after { left: 9px; top: 5px; width: 5px; height: 10px; border: solid ${COLORS.white}; border-width: 0 3px 3px 0; -webkit-transform: rotate(45deg); -ms-transform: rotate(45deg); transform: rotate(45deg); } } `; const Checkbox = (props: IProps) => { const { onHandleChecked, label, checked } = props; return ( <Styled> <div className="container" onClick={onHandleChecked}> <input type="checkbox" checked={checked} /> <span className="checkmark" /> </div> <p>{label}</p> </Styled> ); }; Checkbox.propTypes = { onHandleChecked: PropTypes.func, }; export default Checkbox;
jayce-incognito/leapxpert-test-fe
src/module/Home/Home.tsx
import React from 'react'; import styled from 'styled-components'; import { Todo } from 'src/module/Todo'; declare global { interface Window { ReactNativeWebView: any; } } const Styled = styled.div``; const Home = () => { return ( <Styled> <Todo /> </Styled> ); }; export default React.memo(Home);
jayce-incognito/leapxpert-test-fe
src/module/Todo/Todo.selector.ts
<gh_stars>0 import { createSelector } from 'reselect'; import { IRootState } from 'src/redux/interface'; import { TODO_MODE, TODO_STATUS } from './Todo.constant'; export const todoSelector = createSelector( (state: IRootState) => state.todo, (todo) => todo, ); export const listTodoSelector = createSelector(todoSelector, ({ list, mode }) => { switch (mode) { case TODO_MODE.ALL: return list; case TODO_MODE.ACTIVE: return list.filter((todo) => todo?.status === TODO_STATUS.ACTIVE); case TODO_MODE.DONE: return list.filter((todo) => todo?.status === TODO_STATUS.DONE); default: return list; } }); export const modeActivedSelector = createSelector(todoSelector, ({ mode }) => mode);
jayce-incognito/leapxpert-test-fe
src/module/Tooltip/Tooltip.selector.ts
import { createSelector } from 'reselect'; import { IRootState } from 'src/redux/interface'; import { ITooltipReducer } from './Tooltip.reducer'; export const tooltipSelector = createSelector( (state: IRootState) => state.tooltip, (tooltip: ITooltipReducer) => tooltip.data, );
jayce-incognito/leapxpert-test-fe
src/module/Tooltip/Tooltip.reducer.ts
import { v4 } from 'uuid'; import { ACTION_SHOW_TOOLTIP, ACTION_REMOVE_TOOLTIP } from './Tooltip.constant'; export interface ITooltipReducer { data: Array<any>; } const initialState: ITooltipReducer = { data: [], }; const reducer = ( state = initialState, action: { type: string; payload: any; }, ) => { switch (action.type) { case ACTION_SHOW_TOOLTIP: { let { data: tooltips } = state; const tooltip = action.payload; if (!tooltip.id) { tooltip.id = v4(); } const newData = [...tooltips, tooltip]; return { ...state, data: newData, }; } case ACTION_REMOVE_TOOLTIP: { let { data: tooltips } = state; const removeTooltipId = action.payload; const newData = [...tooltips.filter((item) => item.id !== removeTooltipId)]; return { ...state, data: newData, }; } default: return state; } }; export default reducer;
jayce-incognito/leapxpert-test-fe
src/components/ReduxForm/index.ts
export { default as validator } from './validator'; export { default as InputField } from './InputField';
jayce-incognito/leapxpert-test-fe
src/components/Core/ToggleSwitch/index.ts
<filename>src/components/Core/ToggleSwitch/index.ts export { default as ToggleSwitch } from './ToggleSwitch';
jayce-incognito/leapxpert-test-fe
src/module/Home/Home.selector.ts
<filename>src/module/Home/Home.selector.ts import { createSelector } from 'reselect'; export const templateSelector = createSelector( (state: any) => state.template, (template) => template, );
jayce-incognito/leapxpert-test-fe
src/module/Todo/index.ts
export { default as Todo } from './Todo'; export * from './Todo.actions'; export * from './Todo.constant'; export * from './Todo.interface'; export * from './Todo.reducer'; export * from './Todo.selector'; export * from './Todo.route';
jayce-incognito/leapxpert-test-fe
src/hooks/index.ts
<gh_stars>0 export { default as useDetectClickOutside } from './useDetectClickOutside'; export { default as useValidator } from './useValidator'; export * from './useFormValue';
jayce-incognito/leapxpert-test-fe
src/components/Templates/Templates.route.ts
import { lazy } from 'react'; import { IRouteProps } from 'src/module'; const templatesRoute: IRouteProps = { path: '/templates', exact: true, component: lazy(() => import('./Templates')), name: 'Templates', to: '/templates', }; export const route = templatesRoute.path; export default templatesRoute;
jayce-incognito/leapxpert-test-fe
src/module/Tooltip/TooltipContainer.tsx
import React from 'react'; import { useSelector } from 'react-redux'; import isEmpty from 'lodash/isEmpty'; import { themeSelector } from 'src/module/Setting'; import styled from 'styled-components'; import enhance from './TooltipContainer.enhance'; import { IProps } from './Tooltip.interface'; import Tooltip from './Tooltip'; const Styled = styled.div` position: fixed; left: 0; top: 0; width: 100%; height: 100%; z-index: 10000; pointer-events: none; `; const TooltipContainer = (props: IProps) => { const { tooltips } = props; const theme = useSelector(themeSelector); if (isEmpty(tooltips)) { return null; } const renderContent = () => { return tooltips.map((item: any) => <Tooltip data={item} key={item.id} />); }; return ( <Styled className="tooltip-wrapper" theme={theme}> {renderContent()} </Styled> ); }; export default enhance(React.memo(TooltipContainer));
jayce-incognito/leapxpert-test-fe
src/module/Todo/Todo.constant.ts
export const ACTION_ADD_TODO = `[Todo] Add todo`; export const ACTION_REMOVE_TODO = `[Todo] Remove todo`; export const ACTION_CHANGE_STATUS = `[Todo] Change status todo`; export const ACTION_TOGGLE_ALL_TODO = `[Todo] Toggle all todo`; export const ACTION_CHANGE_MODE = `[Todo] Change mode`; export const TODO_STATUS = { ACTIVE: 0, DONE: 1, }; export const TODO_MODE = { ALL: -1, ACTIVE: 0, DONE: 1, };
jayce-incognito/leapxpert-test-fe
src/hooks/useFormValue.tsx
import trim from 'lodash/trim'; import { useSelector } from 'react-redux'; import { formValueSelector } from 'redux-form'; interface IProps { formName: string; field: string; } export const useFormValue = (props: IProps) => { const { formName, field } = props; const formValue = useSelector((state) => formValueSelector(formName)(state, field)); const trimValue = trim(formValue).replace(/\n/g, ' '); const value = trimValue; return [value]; };
jayce-incognito/leapxpert-test-fe
src/module/Tooltip/TooltipContainer.enhance.tsx
<gh_stars>0 import React from 'react'; import { compose } from 'recompose'; import { useSelector } from 'react-redux'; import { IProps } from './Tooltip.interface'; import { tooltipSelector } from './Tooltip.selector'; const enhance = (WrappedComponent: React.FunctionComponent<IProps>) => (props: IProps) => { const tooltips = useSelector(tooltipSelector); return <WrappedComponent {...props} tooltips={tooltips} />; }; export default compose<IProps, any>(enhance);
jayce-incognito/leapxpert-test-fe
src/utils/index.ts
<filename>src/utils/index.ts export const reloadApp = () => { if (typeof window !== 'undefined') { window.location.href = ''; } }; export const isJSONString = (json: any) => { let result = false; try { if (JSON.parse(json)) { result = true; } } catch { // } return result; };
jayce-incognito/leapxpert-test-fe
src/components/Header/Header.tsx
import React from 'react'; import styled from 'styled-components'; import { ArrowLeftIcon } from 'src/components/Icons'; import { useHistory } from 'react-router-dom'; const Styled = styled.div` &.header { margin-bottom: 30px; } `; const Header = () => { const history = useHistory(); const handleClick = () => { history.goBack(); }; return ( <Styled className="header"> <ArrowLeftIcon onClick={handleClick} /> </Styled> ); }; export default React.memo(Header);
jayce-incognito/leapxpert-test-fe
src/components/Icons/ArrowLeft.tsx
<gh_stars>0 import React from 'react'; import styled from 'styled-components'; interface IProps {} const Styled = styled.button` width: 9px; height: 100%; margin-right: 15px; `; const ArrowLeftVector = React.memo((props: any) => { return ( <svg width={9} height={16}> <path d="M7.912 15.283a.788.788 0 00.809-.8.826.826 0 00-.238-.57L2.085 7.653l6.398-6.258a.843.843 0 00.238-.57c0-.458-.352-.8-.809-.8a.782.782 0 00-.571.228L.37 7.074a.778.778 0 00-.246.58c0 .22.08.413.246.58l6.97 6.812c.15.158.343.237.571.237z" fill="#000" fillRule="nonzero" {...props} /> </svg> ); }); const ArrowLeft = (props: IProps & React.ButtonHTMLAttributes<HTMLButtonElement>) => { return ( <Styled {...props}> <ArrowLeftVector /> </Styled> ); }; export default ArrowLeft;
jayce-incognito/leapxpert-test-fe
src/components/Icons/Eye.tsx
<reponame>jayce-incognito/leapxpert-test-fe import React from 'react'; import { ENVS } from 'src/configs'; import styled from 'styled-components'; interface IProps { toggle?: boolean; } const Styled = styled.button` width: 20px; height: 13px; `; const Eye = (props: IProps & React.ButtonHTMLAttributes<HTMLButtonElement>) => { const { toggle } = props; return ( <Styled className="icon" {...props} type="button"> <img src={`${ENVS.REACT_APP_DOMAIN_URL}/images/icons/${toggle ? '' : 'closed-'}eye.png`} alt="toggle-input" /> </Styled> ); }; export default Eye;
jayce-incognito/leapxpert-test-fe
src/module/Setting/Setting.selector.ts
<reponame>jayce-incognito/leapxpert-test-fe import { createSelector } from 'reselect'; import { IRootState } from 'src/redux/interface'; import { isDev as isDevelop } from 'src/configs'; import { translateByLanguage } from 'src/i18n'; import result from 'lodash/result'; export const settingSelector = createSelector( (state: IRootState) => state.setting, (setting) => setting, ); export const devSettingSelector = createSelector(settingSelector, (setting) => setting.dev); export const isDevSelector = createSelector(settingSelector, (setting) => !!setting.isDev || !!isDevelop); export const themeSelector = createSelector(settingSelector, (setting) => setting.theme); export const darkModeSelector = createSelector(settingSelector, (setting) => setting.darkMode); export const languageSelector = createSelector(settingSelector, (setting) => setting.language); export const translateByFieldSelector = createSelector(languageSelector, (language) => (field: string) => { const translate = translateByLanguage(language); const ts: any = result(translate, field); return ts; }); export const serverSelector = createSelector(settingSelector, (preload) => preload.server || {});
jayce-incognito/leapxpert-test-fe
src/module/Setting/features/Network/Network.route.ts
<gh_stars>0 import { lazy } from 'react'; import { IRouteProps } from 'src/module'; const networkRoute: IRouteProps = { path: '/network', exact: true, component: lazy(() => import('./Network')), name: 'Network', to: '/network', }; export const route = '/network'; export default networkRoute;
jayce-incognito/leapxpert-test-fe
src/components/ErrorBoundary/ErrorBoundary.tsx
import React from 'react'; interface IProps {} interface IState { hasError: boolean; error: any; } class ErrorBoundary extends React.Component<IProps, IState> { constructor(props: any) { super(props); this.state = { hasError: false, error: {} }; } static getDerivedStateFromError = (error: any) => { // Update state so the next render will show the fallback UI. return { hasError: true, error }; }; componentDidCatch = (error: any, errorInfo: any) => { // You can also log the error to an error reporting service console.log(error, errorInfo); }; render() { const { hasError, error } = this.state; const { children } = this.props; if (hasError) { // You can render any custom fallback UI return <h1>Something went wrong. {error?.message || JSON.stringify(error)}</h1>; } return children; } } export default ErrorBoundary;
jayce-incognito/leapxpert-test-fe
src/components/Core/Button/index.ts
<filename>src/components/Core/Button/index.ts export { default as Button } from './Button'; export { default as ButtonRemove } from './ButtonRemove';
jayce-incognito/leapxpert-test-fe
src/module/Setting/features/SettingItem/SettingItem.tsx
<reponame>jayce-incognito/leapxpert-test-fe import React, { SyntheticEvent } from 'react'; import { Link } from 'react-router-dom'; import { ToggleSwitch } from 'src/components/Core'; import { ISettingChildItem, ISettingItem } from './SettingItem.interface'; import { Styled } from './SettingItem.styled'; const ToggleItem = React.memo((props: ISettingChildItem) => { const { desc, onClick, toggleValue } = props; return ( <div className="toggle-item"> {!!desc && <span className="item sub-text" dangerouslySetInnerHTML={{ __html: desc }} />} <ToggleSwitch toggleValue={toggleValue} onToggle={onClick} /> </div> ); }); const Item = React.memo((props: ISettingChildItem) => { const { desc, link, onClick } = props; const handleClickItem = (e: SyntheticEvent) => { if (typeof onClick === 'function') { e.preventDefault(); onClick(); } }; return ( <Link className="item sub-text" to={link || '#'} onClick={handleClickItem}> {desc} </Link> ); }); const SettingItem = React.memo((props: ISettingItem) => { const { title, child, button, onClick } = props; const renderChild = () => { if (!child) return null; return child.map((item: ISettingChildItem) => item.toggle ? <ToggleItem key={item.desc} {...item} /> : <Item key={item.desc} {...item} />, ); }; if (button) { return ( <Styled onClick={onClick}> <p className="title fs-medium fw-medium pointer">{title}</p> </Styled> ); } return ( <Styled> <p className="title fs-medium fw-medium">{title}</p> {renderChild()} </Styled> ); }); export default SettingItem;
jayce-incognito/leapxpert-test-fe
src/module/Home/Home.constant.ts
export const ACTION_FETCHED = `[templates] Fetched data`;
jayce-incognito/leapxpert-test-fe
src/module/Todo/Todo.route.ts
import { lazy } from 'react'; import { IRouteProps } from 'src/module'; const todoRoute: IRouteProps = { path: '/todo', exact: true, component: lazy(() => import('./Todo')), name: 'Todo', to: '/todo', }; export const route = todoRoute.path; export default todoRoute;
jayce-incognito/leapxpert-test-fe
src/module/Todo/Todo.groupActions.tsx
<reponame>jayce-incognito/leapxpert-test-fe<filename>src/module/Todo/Todo.groupActions.tsx import React from 'react'; import { useDispatch, useSelector } from 'react-redux'; import styled from 'styled-components'; import { Button } from 'src/components/Core'; import { TODO_MODE } from './Todo.constant'; import { actionChangeMode, actionToggleAllTodo } from './Todo.actions'; import { modeActivedSelector } from './Todo.selector'; const Styled = styled.div` .btn-action { min-width: 50px; margin-right: 15px; height: 30px; border-radius: 6px; :last-child { margin-right: 0; } } `; const ActionItem = React.memo((props: { value: string; onClickItem: () => void; actived: boolean }) => { const { value, onClickItem, actived } = props; return <Button className="btn-action" onClick={onClickItem} title={value} disabled={!actived} />; }); const TodoGroupActions = () => { const dispatch = useDispatch(); const modeActived = useSelector(modeActivedSelector); const factories = [ { id: TODO_MODE.ALL, value: 'All', }, { id: TODO_MODE.ACTIVE, value: 'Active', }, { id: TODO_MODE.DONE, value: 'Done', }, ]; return ( <Styled className="group-actions flex"> {factories.map(({ id, value }) => ( <ActionItem key={id} actived={modeActived === id} value={value} onClickItem={() => dispatch(actionChangeMode(id))} /> ))} <Button className="btn-action" onClick={() => dispatch(actionToggleAllTodo())} title="Toggle all" /> </Styled> ); }; export default React.memo(TodoGroupActions);
jayce-incognito/leapxpert-test-fe
src/components/Icons/AddressBook.tsx
import React from 'react'; import styled from 'styled-components'; interface IProps {} const Styled = styled.button` width: 16px; height: 18px; `; const AddressBookVector = React.memo((props: any) => { return ( <svg width={16} height={18}> <path d="M7.976 8.848c2.127 0 3.85-1.881 3.85-4.184 0-2.268-1.723-4.07-3.85-4.07-2.119 0-3.859 1.829-3.85 4.088.009 2.294 1.723 4.166 3.85 4.166zm0-1.538c-1.213 0-2.242-1.152-2.242-2.628-.008-1.442 1.02-2.55 2.242-2.55 1.23 0 2.24 1.09 2.24 2.532 0 1.477-1.019 2.646-2.24 2.646zm5.475 9.711c1.52 0 2.25-.483 2.25-1.52 0-2.417-3.014-5.634-7.725-5.634S.24 13.084.24 15.501c0 1.037.73 1.52 2.25 1.52h10.96zm.273-1.538H2.219c-.211 0-.29-.07-.29-.228 0-1.345 2.17-3.85 6.047-3.85 3.867 0 6.038 2.505 6.038 3.85 0 .158-.08.228-.29.228z" fill="#000" fillRule="nonzero" {...props} /> </svg> ); }); const AddressBook = (props: IProps & React.ButtonHTMLAttributes<HTMLButtonElement>) => { const { className = '' } = props; return ( <Styled type="button" className={`icon ${className || ''}`} {...props}> <AddressBookVector /> </Styled> ); }; export default AddressBook;
jayce-incognito/leapxpert-test-fe
src/components/Core/Button/ButtonRemove.tsx
<gh_stars>0 import React from 'react'; import styled from 'styled-components'; import { COLORS } from 'src/styles/colors'; import { ITheme } from 'src/styles'; interface IProps {} const Styled = styled.button` display: flex; justify-content: center; align-items: center; border-radius: 2px; height: 16px; background-color: ${COLORS.red}; color: ${(props: { theme: ITheme }) => props.theme.textButton}; width: 16px; `; const ButtonRemove = (props: IProps & React.ButtonHTMLAttributes<HTMLButtonElement>) => { const { title, disabled, className = '', ...rest } = props; return ( <Styled className={`btn-remove ${className} fs-small`} {...rest}> X </Styled> ); }; export default React.memo(ButtonRemove);
jayce-incognito/leapxpert-test-fe
src/components/Icons/Close.tsx
import React from 'react'; import styled from 'styled-components'; interface IProps {} const Styled = styled.button` width: 11px; height: 11px; `; const CloseVector = React.memo((props: any) => { return ( <svg width={11} height={11} viewBox="0 0 11 11"> <path d="M10.521 10.292a.575.575 0 000-.8L6.458 5.423l4.063-4.062a.569.569 0 00-.806-.8L5.652 4.624 1.59.56a.565.565 0 00-.806 0 .575.575 0 000 .8l4.062 4.062-4.062 4.07a.569.569 0 000 .799c.222.216.59.216.806 0l4.062-4.063 4.063 4.063c.216.216.59.222.806 0z" fill="#000" fillRule="nonzero" {...props} /> </svg> ); }); const Close = (props: IProps & React.ButtonHTMLAttributes<HTMLButtonElement>) => { return ( <Styled className="icon close-icon" {...props}> <CloseVector /> </Styled> ); }; export default Close;
jayce-incognito/leapxpert-test-fe
src/module/Todo/Todo.actions.ts
<reponame>jayce-incognito/leapxpert-test-fe<filename>src/module/Todo/Todo.actions.ts<gh_stars>0 import { ITodo } from './Todo.interface'; import { ACTION_ADD_TODO, ACTION_REMOVE_TODO, ACTION_CHANGE_STATUS, ACTION_TOGGLE_ALL_TODO, TODO_STATUS, ACTION_CHANGE_MODE, } from './Todo.constant'; export const actionAddTodo = (todo: ITodo) => ({ type: ACTION_ADD_TODO, payload: { ...todo, status: TODO_STATUS.ACTIVE, }, }); export const actionRemoveTodo = (id: string) => ({ type: ACTION_REMOVE_TODO, payload: id, }); export const actionChangeStatus = (todo: ITodo) => ({ type: ACTION_CHANGE_STATUS, payload: todo, }); export const actionToggleAllTodo = () => ({ type: ACTION_TOGGLE_ALL_TODO, }); export const actionChangeMode = (mode: number) => ({ type: ACTION_CHANGE_MODE, payload: mode, });
jayce-incognito/leapxpert-test-fe
src/configs/index.ts
<reponame>jayce-incognito/leapxpert-test-fe export * from './configsEnvs';
jayce-incognito/leapxpert-test-fe
src/components/Icons/VerifiedToken.tsx
import React from 'react'; import { ENVS } from 'src/configs'; import styled from 'styled-components'; const Styled = styled.div` width: 14px; height: 14px; `; const VerifiedIcon = () => { return ( <Styled className="icon"> <img src={`${ENVS.REACT_APP_DOMAIN_URL}/images/icons/verified-token.png`} alt="" /> </Styled> ); }; export default React.memo(VerifiedIcon);
jayce-incognito/leapxpert-test-fe
src/App.styled.ts
import styled from 'styled-components'; import { ITheme } from 'src/styles'; export const Styled = styled.div` .preload-container { } .lost-network { background-color: ${(props: { theme: ITheme }) => props.theme.body}; color: ${(props: { theme: ITheme }) => props.theme.text}; left: 0px; top: 0px; right: 0px; bottom: 0px; .icon { margin-bottom: 15px; } } `;
jayce-incognito/leapxpert-test-fe
src/module/Setting/Setting.enhance.tsx
<reponame>jayce-incognito/leapxpert-test-fe import React from 'react'; import ErrorBoundary from 'src/components/ErrorBoundary'; import { useDispatch, useSelector } from 'react-redux'; import { translateByFieldSelector } from 'src/module/Setting'; import Header from 'src/components/Header'; import { ISettingLanguage } from './Setting.interface'; import { actionToggleDarkMode } from './Setting.actions'; import { ISettingItem } from './features/SettingItem'; import { serverSelector, settingSelector } from './Setting.selector'; import { route as networkRoute } from './features/Network/Network.route'; interface IProps {} interface TInner { settingFactories: any[]; } export interface IMergeProps extends IProps, TInner {} const enhance = (WrappedComponent: React.FunctionComponent) => (props: any) => { const translate: ISettingLanguage = useSelector(translateByFieldSelector)('setting'); const dispatch = useDispatch(); const { darkMode } = useSelector(settingSelector); const server = useSelector(serverSelector); let settingFactories: ISettingItem[] = [ { title: translate.darkMode.title, child: [ { desc: translate.darkMode.desc, toggle: true, onClick: () => dispatch(actionToggleDarkMode(!darkMode)), toggleValue: darkMode, }, ], }, ]; return ( <ErrorBoundary> <Header /> <WrappedComponent {...{ ...props, settingFactories }} /> </ErrorBoundary> ); }; export default enhance;
jayce-incognito/leapxpert-test-fe
src/module/Tooltip/Tooltip.interface.ts
<gh_stars>0 export interface IProps { tooltips: Array<any>; } export interface ITooltipProps { data: { timeout?: number; id: string; text: string; className?: any; ref?: any; width?: number; height?: number; margin?: number; }; tooltipPosition?: { top: number; bottom: number; left: number; right: number; }; }
jayce-incognito/leapxpert-test-fe
src/components/Core/FillCheckBox/FillCheckBox.tsx
import React from 'react'; import styled from 'styled-components'; const Styled = styled.button` &.wrapper { display: flex; flex-direction: row; } .icon-checkbox { min-width: 18px; height: 18px; } .label { margin-left: 5px; text-align: left; } `; interface ICheckBoxProps { checked: boolean; label: string; onHandleChecked: () => any; } const CheckedBoxVector = React.memo((props: any) => { return ( <svg width="18" height="18" viewBox="0 0 15 15" {...props}> <path d="M12.147 14.567c1.59 0 2.41-.82 2.41-2.387V3.266c0-1.567-.82-2.388-2.41-2.388h-8.87c-1.582 0-2.41.813-2.41 2.388v8.914c0 1.567.828 2.387 2.41 2.387h8.87zm-5.23-3.237c-.278 0-.505-.117-.71-.388L4.413 8.767a.826.826 0 01-.198-.52c0-.381.3-.689.681-.689.227 0 .403.08.593.322l1.407 1.78L9.92 4.826c.154-.256.367-.38.594-.38.373 0 .71.256.71.644 0 .168-.088.351-.19.513l-3.435 5.339a.782.782 0 01-.682.388z" fill="#000" fillRule="nonzero" /> </svg> ); }); const CheckBoxVector = React.memo((props: any) => { return ( <svg width="18" height="18" viewBox="0 0 15 15" {...props}> <path d="M12.147 14.567c1.59 0 2.41-.82 2.41-2.387V3.266c0-1.567-.82-2.388-2.41-2.388h-8.87c-1.582 0-2.41.813-2.41 2.388v8.914c0 1.567.828 2.387 2.41 2.387h8.87zm-.095-1.457h-8.68c-.673 0-1.047-.352-1.047-1.062v-8.65c0-.71.374-1.062 1.048-1.062h8.679c.666 0 1.047.352 1.047 1.062v8.65c0 .71-.38 1.062-1.047 1.062z" fill="#000" fillRule="nonzero" /> </svg> ); }); const FillCheckBox = React.memo((props: ICheckBoxProps & any) => { const { checked, label, onHandleChecked } = props; return ( <Styled className="wrapper icon btn-fill-check-box" onClick={onHandleChecked}> <div className="icon-checkbox">{checked ? <CheckedBoxVector /> : <CheckBoxVector />}</div> <p className="fs-regular fw-regular sub-text label">{label}</p> </Styled> ); }); export default FillCheckBox;
jayce-incognito/leapxpert-test-fe
src/index.tsx
import React from 'react'; import ReactDOM from 'react-dom'; import App from './App'; const rootEl = document.getElementById('root'); ReactDOM.render(<App />, rootEl); if (module.hot) { module.hot.accept(); }
jayce-incognito/leapxpert-test-fe
src/styles/index.ts
export * from './globalStyles'; export * from './colors'; export * from './fontSize';
jayce-incognito/leapxpert-test-fe
src/module/Todo/Todo.interface.ts
export interface IProps {} export interface ITodo { id: string; status: number; value: string; }
jayce-incognito/leapxpert-test-fe
src/styles/globalStyles.ts
<reponame>jayce-incognito/leapxpert-test-fe import { ENVS } from 'src/configs'; import { createGlobalStyle } from 'styled-components'; import { COLORS } from './colors'; import { FONT_SIZES } from './fontSize'; export interface ITheme { body: string; text: string; inverseBody: string; inverseText: string; subText: string; toggleBorder: string; gradient: string; button: string; textButton: string; width: string; minWidth: string; maxWidth: string; height: string; tooltipBg: string; tooltipText: string; input: string; inputBorder: string; inputTextColor: string; modalBg: string; switchButton: string; switchActiveButton: string; typeButton: string; typeTextButton: string; disableButton: string; disableTextButton: string; copyButton: string; copyTextButton: string; copyBorderButton: string; fastFeeButton: string; fastFeeBorderButton: string; fastFeeTextButton: string; toastBg: string; } export interface IGlobalStyle { theme: ITheme; } export const lightTheme: ITheme = { body: COLORS.white, inverseBody: COLORS.black, text: COLORS.black, inverseText: COLORS.white, subText: COLORS.colorGreyBold, toggleBorder: COLORS.white, gradient: 'linear-gradient(#39598A, #79D7ED)', button: COLORS.black1, textButton: COLORS.white, width: '100vw', minWidth: '220px', maxWidth: '375px', height: '600px', tooltipBg: COLORS.black, tooltipText: COLORS.white, input: COLORS.colorGrey, inputBorder: COLORS.colorKeyGrey, inputTextColor: COLORS.black4, modalBg: COLORS.white, switchButton: COLORS.lightGrey22, switchActiveButton: COLORS.black1, typeButton: COLORS.colorGrey, typeTextButton: COLORS.colorGreyBold, disableButton: 'rgba(51, 53, 52, 0.3)', disableTextButton: COLORS.white, copyButton: COLORS.colorGrey, copyTextButton: COLORS.colorGreyBold, copyBorderButton: COLORS.colorKeyGrey, fastFeeButton: COLORS.colorGrey, fastFeeBorderButton: COLORS.colorKeyGrey, fastFeeTextButton: COLORS.colorGreyBold, toastBg: COLORS.colorGrey, }; export const darkTheme: ITheme = { body: COLORS.black2, text: COLORS.white, inverseText: COLORS.black, inverseBody: COLORS.white, subText: COLORS.colorGreyBold, toggleBorder: '#6B8096', gradient: 'linear-gradient(#091236, #1E215D)', button: COLORS.black1, textButton: COLORS.white, width: '357px', minWidth: '320px', maxWidth: '375px', height: '600px', tooltipBg: COLORS.white, tooltipText: COLORS.black, input: COLORS.black2, inputBorder: COLORS.black1, inputTextColor: COLORS.white, modalBg: COLORS.black1, switchButton: COLORS.black1, switchActiveButton: COLORS.lightGrey22, typeButton: COLORS.black2, typeTextButton: COLORS.colorGreyBold, disableButton: COLORS.black3, disableTextButton: COLORS.colorGreyBold, copyButton: COLORS.black2, copyTextButton: COLORS.white, copyBorderButton: COLORS.black1, fastFeeButton: COLORS.black2, fastFeeBorderButton: COLORS.black1, fastFeeTextButton: COLORS.colorGreyBold, toastBg: COLORS.black3, }; export const DEFAULT_THEME = lightTheme; export const GlobalStyled = createGlobalStyle` html { background: ${COLORS.lightGrey19}; } #root { background: ${(props: IGlobalStyle) => props.theme.body}; color: ${(props: IGlobalStyle) => props.theme.text}; scrollbar-color: transparent transparent; /*just hides the scrollbar for firefox */ font-family: 'SF-Pro-Display'; font-style: normal; font-display: swap; box-sizing: border-box; font-weight: 400; height: 100vh; width: 100vw; border: none; position: relative; font-size: ${FONT_SIZES.regular}px; line-height: ${FONT_SIZES.regular + 3}px; min-width: 320px; max-width: 414px; margin: auto; overflow: hidden; padding: 25px; * { box-sizing: border-box; font-family: 'SF-Pro-Display'; } } #root.incognito-extension-tab { margin-top: 40px; margin-bottom: 100px; border-radius: 30px; border: 1px solid ${COLORS.lightGrey21}; }\ #root.incognito-extension-tab .modal-content-wrapper{ margin-top: 40px; border-radius: 30px; } @font-face { font-family: 'SF-Pro-Display'; src: url('${ENVS.REACT_APP_DOMAIN_URL}/fonts/SF-Pro-Display/SF-Pro-Display-Regular.otf'); font-style: normal; font-display: swap; font-weight: 400; } @font-face { font-family: 'SF-Pro-Display'; src: url('${ENVS.REACT_APP_DOMAIN_URL}/fonts/SF-Pro-Display/SF-Pro-Display-Bold.otf'); font-style: normal; font-display: swap; font-weight: 700; } @font-face { font-family: 'SF-Pro-Display'; src: url('${ENVS.REACT_APP_DOMAIN_URL}/fonts/SF-Pro-Display/SF-Pro-Display-Medium.otf'); font-style: normal; font-display: swap; font-weight: 500; } .fw-regular{ font-weight: 400; } .fw-medium{ font-weight: 500; } .fw-light{ font-weight: 200; } .fw-bold { font-weight: 700; } .fs-small { font-size: ${FONT_SIZES.small}px; line-height: ${FONT_SIZES.small + 3}px; } .fs-regular { font-size: ${FONT_SIZES.regular}px; line-height: ${FONT_SIZES.regular + 3}px; } .fs-medium { font-size: ${FONT_SIZES.medium}px; line-height: ${FONT_SIZES.medium + 3}px; } .fs-supermedium { font-size: ${FONT_SIZES.superMedium}px; line-height: ${FONT_SIZES.superMedium + 3}px; } .fs-large{ font-size: ${FONT_SIZES.large}px; line-height: ${FONT_SIZES.large + 3}px; } .fs-avglarge{ font-size: ${FONT_SIZES.avgLarge}px; line-height: ${FONT_SIZES.avgLarge + 3}px; } .fs-verylarge{ font-size: ${FONT_SIZES.veryLarge}px; line-height: ${FONT_SIZES.veryLarge + 3}px; } .hook-row { display: flex; flex-direction: row; align-items: center; } .hook-row-space-between { display: flex; flex-direction: row; align-items: center; justify-content: space-between; } .hook-column { } .right-text{ text-align: right; } .center-text{ text-align: center; } .left-text{ text-align: left; } .main-text { color: ${(props: IGlobalStyle) => props.theme.text}; } .sub-text { color: ${(props: IGlobalStyle) => props.theme.subText}; } .inverse-text { color: ${(props: IGlobalStyle) => props.theme.inverseText}; } .flex { display: flex; align-items: center; } .flex-jcb { display: flex; align-items: center; justify-content: space-between; } .icon { position: relative; > img { position: absolute; left: 0; right: 0; bottom: 0; top: 0; } > svg { position: absolute; left: 0; right: 0; bottom: 0; top: 0; width: 100%; height: 100%; } } .icon-abs { position: absolute; left: 0; right: 0; bottom: 0; top: 0; } .icon { margin-left: 15px; } .scroll-view { position: relative; overflow-x: hidden; overflow-y: scroll; max-height: 518px; padding-bottom: 30px; } .linear-bg { background: linear-gradient(rgba(0,0,0,0.6), rgba(0,0,0,0.5), rgba(0,0,0,0.6)) !important; } .hidden { display: none; } .error-message { color: ${COLORS.orange}; font-size: 14px; margin-top: 10px; } .p-l-15 { padding-left: 15px; } .m-b-30 { margin-bottom: 30px; } .m-t-50 { margin-top: 50px; } .m-t-30 { margin-top: 30px !important; } .m-r-15 { margin-right: 15px; } .m-b-10 { margin-bottom: 10px; } .center-abs-ver { position: absolute; top: 50%; transform: translateY(-50%); } .center-abs-hor { position: absolute; left: 50%; transform: translateX(-50%); } .success { color: ${COLORS.green}; } .error { color: ${COLORS.red}; } .warning { color: ${COLORS.orange}; } .text-color-grey { color: ${COLORS.newGrey}; } .text-color-black { color: ${COLORS.black}; } .m-t-15 { margin-top: 15px; } svg { path { fill: ${(props: { theme: ITheme }) => props.theme.text}; } } // Remove eye icon for password input on Edge Chromium input::-ms-reveal, input::-ms-clear { display: none; } .pointer { cursor: pointer; } .modal-data .label { margin-bottom: 30px; } .group-button { > button { flex : 1 0 auto; max-width: 48%; } } `;
jayce-incognito/leapxpert-test-fe
src/module/Setting/Setting.actions.ts
<reponame>jayce-incognito/leapxpert-test-fe<filename>src/module/Setting/Setting.actions.ts import { IServer } from 'src/services'; import { ACTION_FETCHED, ACTION_TOGGLE_HOME_CONFIGS, ACTION_TOGGLE_DECIMAL_DIGITS, ACTION_TOGGLE_DEV_MODE, ACTION_TOGGLE_MODE_SAVE_BURN_TX, ACTION_TOGGLE_MODE_SAVE_RAW_BURN_TX, ACTION_TOGGLE_DARK_MODE, ACTION_CHANGE_LANGUAGE, ACTION_SET_SERVER, } from './Setting.constant'; export const actionFetched = (payload: any) => ({ type: ACTION_FETCHED, payload, }); export const actionToggleHomeConfigs = () => ({ type: ACTION_TOGGLE_HOME_CONFIGS, }); export const actionToggleDecimalDigits = () => ({ type: ACTION_TOGGLE_DECIMAL_DIGITS, }); export const actionToggleDevMode = () => ({ type: ACTION_TOGGLE_DEV_MODE, }); export const actionToggleModeSaveBurnTx = () => ({ type: ACTION_TOGGLE_MODE_SAVE_BURN_TX, }); export const actionToggleModeSaveRawBurnTx = () => ({ type: ACTION_TOGGLE_MODE_SAVE_RAW_BURN_TX, }); export const actionToggleDarkMode = (payload: boolean) => ({ type: ACTION_TOGGLE_DARK_MODE, payload, }); export const actionChangeLanguage = (language: string) => ({ type: ACTION_CHANGE_LANGUAGE, payload: language, }); export const actionSetServer = (payload: IServer) => ({ type: ACTION_SET_SERVER, payload, });
jayce-incognito/leapxpert-test-fe
src/module/Tooltip/Tooltip.actions.ts
<reponame>jayce-incognito/leapxpert-test-fe<filename>src/module/Tooltip/Tooltip.actions.ts import { ACTION_SHOW_TOOLTIP, ACTION_REMOVE_TOOLTIP } from './Tooltip.constant'; export const actionShowTooltip = ({ id = '', text, timeout = 2, ref, width = 200, height = 100, margin = 10, }: { id?: string; text: any; timeout?: number; ref: any; width?: number; height?: number; margin?: number; }) => ({ type: ACTION_SHOW_TOOLTIP, payload: { id, text, timeout, ref, width, height, margin }, }); export const actionRemoveTooltip = (id: string) => ({ type: ACTION_REMOVE_TOOLTIP, payload: id, });
jayce-incognito/leapxpert-test-fe
src/module/Tooltip/index.ts
export { default } from './Tooltip'; export * from './Tooltip.actions'; export * from './Tooltip.constant'; export * from './Tooltip.interface'; export * from './Tooltip.reducer'; export * from './Tooltip.selector'; export { default as TooltipContainer } from './TooltipContainer'; export { default as TooltipWrapper } from './Tooltip.wrapper';
jayce-incognito/leapxpert-test-fe
src/module/Setting/Setting.interface.ts
<filename>src/module/Setting/Setting.interface.ts export interface ISettingLanguage { headerTitle: string; network: { title: string; }; dev: { title: string; homeConfigs: string; }; addressBook: { title: string; desc: string; }; keychain: { title: string; desc: string; }; decimalDigits: { title: string; desc: string; }; darkMode: { title: string; desc: string; }; logout: { title: string; }; }
jayce-incognito/leapxpert-test-fe
src/components/ReduxForm/InputField/index.ts
<filename>src/components/ReduxForm/InputField/index.ts export { default } from './InputField'; export * from './InputField'; export * from './InputField.constant';
jayce-incognito/leapxpert-test-fe
src/components/Icons/AppIcon.tsx
<filename>src/components/Icons/AppIcon.tsx import React from 'react'; import styled from 'styled-components'; import { ENVS } from 'src/configs'; const Styled = styled.img` width: 22px; height: 22px; border-radius: 50%; border: solid 0.5px; `; const AppIcon = (props: any) => { return <Styled src={`${ENVS.REACT_APP_DOMAIN_URL}/images/icons/app_logo.png`} className="app-icon" {...props} />; }; export default React.memo(AppIcon);
jayce-incognito/leapxpert-test-fe
src/components/Icons/index.ts
export { default as SettingIcon } from './Setting'; export { default as QrCodeIcon } from './QrCode'; export { default as ArrowLeftIcon } from './ArrowLeft'; export { default as VerifiedIcon } from './VerifiedToken'; export { default as CopyIcon } from './Copy'; export { default as OpenLinkIcon } from './OpenLink'; export { default as QuestionIcon } from './Question'; export { default as InfoIcon } from './Info'; export { default as InfiniteIcon } from './Infinite'; export { default as ScanIcon } from './Scan'; export { default as AddressBookIcon } from './AddressBook'; export { default as ArrowUpIcon } from './ArrowUp'; export { default as ArrowDownIcon } from './ArrowDown'; export { default as CloseIcon } from './Close'; export { default as RefreshIcon } from './Refresh'; export { default as LoadingIcon } from './Loading'; export { default as ClockWiseIcon } from './ClockWise'; export { default as AddCircleIcon } from './AddCircle'; export { default as TrashBinIcon } from './TrashBin'; export { default as KeyIcon } from './Key'; export { default as EyeIcon } from './Eye'; export { default as LostConnectIcon } from './LostConnect'; export { default as FastFeeIcon } from './FastFee'; export { default as AppIcon } from './AppIcon'; export { default as WarningIcon } from './Warning';
jayce-incognito/leapxpert-test-fe
src/components/Core/Tabs/index.ts
<filename>src/components/Core/Tabs/index.ts export { default } from './Tabs'; export { default as Tab } from './Tabs.tab'; export * from './Tabs.interface'; export * from './Tabs.constant';
jayce-incognito/leapxpert-test-fe
src/components/Icons/Scan.tsx
import React from 'react'; import styled from 'styled-components'; interface IProps {} const Styled = styled.button` width: 17px; height: 17px; `; const ScanVector = React.memo((props: any) => { return ( <svg width={17} height={17}> <path d="M15.703 5.86c.508 0 .781-.282.781-.79V3.172c0-1.672-.875-2.547-2.57-2.547h-1.898c-.508 0-.79.273-.79.781 0 .5.282.774.79.774h1.796c.711 0 1.118.375 1.118 1.132V5.07c0 .508.273.79.773.79zm-13.93 0c.508 0 .774-.282.774-.79V3.312c0-.757.398-1.132 1.117-1.132h1.797c.508 0 .789-.274.789-.774 0-.508-.281-.781-.79-.781H3.564c-1.688 0-2.57.867-2.57 2.547V5.07c0 .508.28.79.78.79zm3.688 10.257c.508 0 .789-.281.789-.781s-.281-.781-.79-.781H3.665c-.719 0-1.117-.367-1.117-1.125v-1.758c0-.508-.274-.79-.774-.79-.507 0-.78.282-.78.79v1.898c0 1.672.882 2.547 2.57 2.547H5.46zm8.453 0c1.695 0 2.57-.875 2.57-2.547v-1.898c0-.508-.28-.79-.78-.79-.509 0-.774.282-.774.79v1.758c0 .758-.407 1.125-1.117 1.125h-1.797c-.508 0-.79.28-.79.78s.282.782.79.782h1.898z" fill="#000" fillRule="nonzero" {...props} /> </svg> ); }); const Scan = (props: IProps & React.ButtonHTMLAttributes<HTMLButtonElement>) => { const { className = '' } = props; return ( <Styled type="button" className={`icon ${className || ''}`} {...props}> <ScanVector /> </Styled> ); }; export default Scan;
jayce-incognito/leapxpert-test-fe
src/components/Core/TextArea/TextArea.tsx
import React, { ChangeEvent, TextareaHTMLAttributes } from 'react'; import styled from 'styled-components'; import { COLORS } from 'src/styles'; interface IProps extends TextareaHTMLAttributes<HTMLTextAreaElement> { onChange?: (e: ChangeEvent<HTMLTextAreaElement>) => void; label?: string; borderless?: boolean; } const Styled = styled.div` label { font-size: 18px; font-weight: medium; } textarea { width: 100%; padding: 10px; border: 1px solid ${COLORS.colorKeyGrey}; border-radius: 8px; background-color: ${COLORS.colorGrey}; resize: none; font-weight: 100; &.borderless { border: none; background-color: transparent; padding: 10px 0; font-size: 18px; font-weight: medium; } } textarea::placeholder { color: ${COLORS.colorGreyBold}; font-weight: 100; } `; const TextArea = (props: IProps) => { const { name, label, borderless } = props; return ( <Styled className="layout-container"> {!!label && <label htmlFor={name}>{label}</label>} <textarea {...props} className={borderless ? 'borderless' : ''} /> </Styled> ); }; export default TextArea;
jayce-incognito/leapxpert-test-fe
src/hooks/useValidator.tsx
<reponame>jayce-incognito/leapxpert-test-fe import React from 'react'; interface IProps { validator: any[]; } const useValidator = (props: IProps) => { const { validator } = props; const [validate, setValidate] = React.useState<Array<any>>([]); React.useEffect(() => { setValidate([...validator]); }, []); return [validate]; }; export default useValidator;
jayce-incognito/leapxpert-test-fe
src/components/Icons/Loading.tsx
import React from 'react'; import { IGlobalStyle } from 'src/styles'; import styled from 'styled-components'; export interface ILoadingIconProps { width?: string; height?: string; center?: boolean; } const Styled: any = styled.div` position: relative; width: ${(props: ILoadingIconProps) => props.width}; height: ${(props: ILoadingIconProps) => props.height}; &.loading-center { margin: auto; } .spinner-border { position: absolute; left: 0; top: 0; width: 100%; height: 100%; } .spinner { width: ${(props: ILoadingIconProps) => props.width}; height: ${(props: ILoadingIconProps) => props.height}; display: inline-block; } div.spinner div { width: 9%; height: 28%; background: ${(props: IGlobalStyle) => props.theme.text}; position: absolute; left: 49%; top: 43%; opacity: 0; border-radius: 50px; animation: fade 1s linear infinite; } @keyframes fade { from { opacity: 1; } to { opacity: 0; } } div.spinner div.bar1 { transform: rotate(0deg) translate(0, -130%); animation-delay: 0s; } div.spinner div.bar2 { transform: rotate(30deg) translate(0, -130%); animation-delay: -0.9167s; } div.spinner div.bar3 { transform: rotate(60deg) translate(0, -130%); animation-delay: -0.833s; } div.spinner div.bar4 { transform: rotate(90deg) translate(0, -130%); animation-delay: -0.7497s; } div.spinner div.bar5 { transform: rotate(120deg) translate(0, -130%); animation-delay: -0.667s; } div.spinner div.bar6 { transform: rotate(150deg) translate(0, -130%); animation-delay: -0.5837s; } div.spinner div.bar7 { transform: rotate(180deg) translate(0, -130%); animation-delay: -0.5s; } div.spinner div.bar8 { transform: rotate(210deg) translate(0, -130%); animation-delay: -0.4167s; } div.spinner div.bar9 { transform: rotate(240deg) translate(0, -130%); animation-delay: -0.333s; } div.spinner div.bar10 { transform: rotate(270deg) translate(0, -130%); animation-delay: -0.2497s; } div.spinner div.bar11 { transform: rotate(300deg) translate(0, -130%); animation-delay: -0.167s; } div.spinner div.bar12 { transform: rotate(330deg) translate(0, -130%); animation-delay: -0.0833s; } `; const LoadingVector = React.memo(() => { return ( <div className="spinner"> {[...Array(12)].map((e, i) => { return <div key={i.toString()} className={`bar${i + 1}`} />; })} </div> ); }); const Loading = (props: ILoadingIconProps) => { const { width = '20px', height = '20px', center } = props; return ( <Styled width={width} height={height} className={`loading-icon ${center ? 'loading-center' : ''}`}> <LoadingVector /> </Styled> ); }; export default Loading;
jayce-incognito/leapxpert-test-fe
src/components/Icons/Refresh.tsx
<reponame>jayce-incognito/leapxpert-test-fe import React from 'react'; import styled from 'styled-components'; interface IProps {} const Styled = styled.button` width: 19px; height: 23px; `; const RefreshVector = React.memo((props: any) => { return ( <svg width={18} height={22}> <path d="M9.38 21.295a8.604 8.604 0 008.624-8.643c0-.468-.332-.81-.81-.81-.46 0-.762.342-.762.81a7.033 7.033 0 01-7.051 7.07 7.042 7.042 0 01-7.06-7.07 7.031 7.031 0 017.06-7.05c.742 0 1.426.058 2.012.185l-2.92 2.9a.808.808 0 00-.225.557c0 .45.332.781.772.781.244 0 .43-.078.566-.224l4.023-4.043a.761.761 0 00.245-.586.837.837 0 00-.245-.586L9.586.504C9.449.348 9.254.27 9.02.27c-.44 0-.772.351-.772.8 0 .205.078.4.215.557l2.607 2.559a9.796 9.796 0 00-1.69-.157 8.602 8.602 0 00-8.632 8.623 8.613 8.613 0 008.633 8.643z" fill="#000" fillRule="nonzero" {...props} /> </svg> ); }); const Refresh = React.forwardRef((props: IProps & React.ButtonHTMLAttributes<HTMLButtonElement>, ref: any) => { return ( <Styled ref={ref} className="icon" {...props}> <RefreshVector /> </Styled> ); }); export default Refresh;
jayce-incognito/leapxpert-test-fe
src/components/Icons/Info.tsx
import React from 'react'; import styled from 'styled-components'; import { COLORS } from 'src/styles'; interface IProps { isGreyIcon?: boolean; } const Styled = styled.button<{ isGreyIcon?: boolean }>` width: 16px; height: 16px; svg { path { fill: ${(props) => props?.isGreyIcon && COLORS.colorGreyBold}; } } `; const InfoVector = React.memo((props: any) => { return ( <svg width={16} height={15}> <path d="M7.782 15.183c4.087 0 7.47-3.391 7.47-7.471 0-4.087-3.39-7.47-7.478-7.47-4.08 0-7.463 3.383-7.463 7.47 0 4.08 3.391 7.47 7.47 7.47zM7.708 5.039a.986.986 0 01-.988-.997.986.986 0 111.97 0 .98.98 0 01-.982.997zm1.817 6.84H6.456a.535.535 0 01-.557-.542c0-.293.242-.534.557-.534h.93V7.36h-.805a.533.533 0 01-.55-.542.54.54 0 01.55-.534H8c.389 0 .594.278.594.688v3.83h.93c.315 0 .557.242.557.535a.535.535 0 01-.557.542z" fill="#000" fillRule="nonzero" {...props} /> </svg> ); }); const Info = React.forwardRef((props: IProps & React.ButtonHTMLAttributes<HTMLButtonElement>, ref: any) => { return ( <Styled className="icon info-icon" ref={ref} {...props}> <InfoVector /> </Styled> ); }); export default Info;
jayce-incognito/leapxpert-test-fe
src/components/Core/Tabs/Tabs.tsx
import React from 'react'; import { useDispatch, useSelector } from 'react-redux'; import { themeSelector } from 'src/module/Setting'; import styled from 'styled-components'; import { actionChangeTab } from './Tabs.actions'; import { IPropsTabs } from './Tabs.interface'; import { activeTabSelector } from './Tabs.selector'; import Tab from './Tabs.tab'; const Styled = styled.div` &.tabs { .tab-list { border-radius: 20px; padding: 2px; } .tab-list .tab { margin-top: unset; flex: 1 0 auto; max-width: 48%; } } `; const Tabs = (props: IPropsTabs) => { const { children } = props; const theme = useSelector(themeSelector); const activeTab = useSelector(activeTabSelector); const dispatch = useDispatch(); const onClickTabItem = (tab: number | string) => dispatch(actionChangeTab(tab)); React.useEffect(() => { if (children) { dispatch(actionChangeTab(children[0].props.tabID)); } }, []); return ( <Styled className="tabs" theme={theme}> <ol className="tab-list flex-jcb"> {children.map((child) => { const { label, tabID } = child.props; return ( <Tab activeTab={activeTab} key={label} label={label} onClickTab={onClickTabItem} tabID={tabID} /> ); })} </ol> <div className="tab-content"> {children.map((child) => { if (child.props.tabID !== activeTab) return null; return child.props.children; })} </div> </Styled> ); }; export default React.memo(Tabs);
jayce-incognito/leapxpert-test-fe
src/configs/configsEnvs.ts
import isEmpty from 'lodash/isEmpty'; interface IENVS { REACT_APP_MODE: string; REACT_APP_IS_DEV: boolean; REACT_APP_DOMAIN_URL: string; REACT_APP_TOGGLE_REDUX_LOGGER: string; } const defaultEnvs = { REACT_APP_MODE: 'development', REACT_APP_IS_DEV: 'true', REACT_APP_DOMAIN_URL: 'http://localhost:3002', REACT_APP_TOGGLE_REDUX_LOGGER: 'false', }; export const getEnvs = () => { let envs: any = {}; try { const PROCCESS_ENV = process.env; if (!isEmpty(PROCCESS_ENV)) { Object.keys(PROCCESS_ENV).map((key: string) => { envs[key] = PROCCESS_ENV[key]; return key; }); } } catch (error) { console.debug(error); } finally { envs = isEmpty(envs) ? defaultEnvs : envs; } return { ...envs, REACT_APP_DOMAIN_URL: window.location.origin }; }; export const ENVS: IENVS = getEnvs(); console.log('ENVS', ENVS); export const isDev: boolean = ENVS.REACT_APP_MODE === 'development'; export const isToggleReduxLogger = ENVS.REACT_APP_TOGGLE_REDUX_LOGGER === 'true';
jayce-incognito/leapxpert-test-fe
src/components/Core/Tabs/Tabs.actions.ts
import { ACTION_CHANGE_TAB } from './Tabs.constant'; export const actionChangeTab = (payload: number | string) => ({ type: ACTION_CHANGE_TAB, payload, });
jayce-incognito/leapxpert-test-fe
src/components/Icons/Warning.tsx
import React from 'react'; import styled from 'styled-components'; interface IProps {} const Styled = styled.button` min-width: 18px; height: 18px; `; const WarningVector = React.memo((props: any) => { return ( <svg width="1em" height="1em" viewBox="0 0 16 15" {...props}> <path d="M13.788 14.633c1.098 0 1.787-.79 1.787-1.787 0-.3-.074-.6-.235-.879L9.576 1.677a1.763 1.763 0 00-3.083 0L.736 11.975a1.798 1.798 0 00-.242.871c0 .996.689 1.787 1.787 1.787h11.507zm-5.75-4.892c-.38 0-.586-.22-.593-.608l-.103-3.985c-.007-.388.279-.666.689-.666.403 0 .703.286.696.674l-.103 3.977c-.007.395-.22.608-.586.608zm0 2.453c-.432 0-.813-.351-.813-.783 0-.44.374-.791.813-.791.447 0 .82.344.82.79 0 .44-.38.784-.82.784z" fill="#000" fillRule="nonzero" /> </svg> ); }); const Warning = (props: IProps & React.ButtonHTMLAttributes<HTMLButtonElement>) => { return ( <Styled className="icon waring-icon" {...props}> <WarningVector /> </Styled> ); }; export default React.memo(Warning);
jayce-incognito/leapxpert-test-fe
src/components/Core/Tabs/Tabs.tab.tsx
<reponame>jayce-incognito/leapxpert-test-fe import React, { HTMLAttributes } from 'react'; import { Button } from 'src/components/Core'; import { IPropsTab } from './Tabs.interface'; const Tab = (props: IPropsTab & HTMLAttributes<HTMLDivElement>) => { const { activeTab, label, onClickTab, tabID } = props; const onClick = () => typeof onClickTab === 'function' && onClickTab(tabID); return <Button title={label} onClick={onClick} className="tab" disabled={tabID !== activeTab} />; }; export default React.memo(Tab);
jayce-incognito/leapxpert-test-fe
src/components/Icons/ArrowUp.tsx
import React from 'react'; import styled from 'styled-components'; interface IProps {} const Styled = styled.button` width: 18px; height: 10px; `; const ArrowUpVector = React.memo((props: any) => { return ( <svg width={16} height={10}> <path d="M14.708 8.6c.457 0 .8-.342.8-.8a.775.775 0 00-.237-.57L8.468.268a.8.8 0 00-1.187 0L.48 7.229a.775.775 0 00-.238.572c0 .457.343.8.8.8.229 0 .44-.08.571-.229L7.88 1.974l6.258 6.398c.14.15.351.229.571.229z" fill="#000" fillRule="nonzero" {...props} /> </svg> ); }); const ArrowUp = (props: IProps & React.ButtonHTMLAttributes<HTMLButtonElement>) => { return ( <Styled className="icon arrow-up-icon" {...props}> <ArrowUpVector /> </Styled> ); }; export default ArrowUp;
jayce-incognito/leapxpert-test-fe
src/module/Tooltip/Tooltip.constant.ts
<reponame>jayce-incognito/leapxpert-test-fe export const ACTION_SHOW_TOOLTIP = '[tooltip] show tooltip'; export const ACTION_REMOVE_TOOLTIP = '[tooltip] remove tooltip';
jayce-incognito/leapxpert-test-fe
src/services/api.ts
<gh_stars>0 export const api = () => null;
jayce-incognito/leapxpert-test-fe
src/components/Core/TyniButton/index.tsx
import React from 'react'; import { useSelector } from 'react-redux'; import { themeSelector } from 'src/module/Setting'; import { COLORS, IGlobalStyle } from 'src/styles'; import styled from 'styled-components'; interface IProps { title: string; selected?: boolean; } const Styled = styled.button` background-color: ${(props: IGlobalStyle) => props.theme.typeButton}; border: solid 0.5px ${(props: IGlobalStyle) => props.theme.inputBorder}; border-radius: 5px; color: ${(props: IGlobalStyle) => props.theme.typeTextButton}; min-width: 54px; height: 23px; margin-left: 5px; &.selected { color: ${COLORS.white}; background-color: ${(props: IGlobalStyle) => props.theme.button}; border: solid transparent 0.5px; } `; const TyniButton = (props: IProps & React.ButtonHTMLAttributes<HTMLButtonElement>) => { const { title, selected, className, ...rest } = props; const theme = useSelector(themeSelector); return ( <Styled theme={theme} className={`${className} ${selected ? 'selected' : ''}`} {...rest}> {title} </Styled> ); }; export default React.memo(TyniButton);
jayce-incognito/leapxpert-test-fe
src/module/Todo/Todo.reducer.ts
import { ITodo } from './Todo.interface'; import { TODO_STATUS, ACTION_ADD_TODO, ACTION_REMOVE_TODO, ACTION_CHANGE_STATUS, ACTION_TOGGLE_ALL_TODO, TODO_MODE, ACTION_CHANGE_MODE, } from './Todo.constant'; export interface ITodoReducer { list: ITodo[]; mode: number; } const initialState: ITodoReducer = { list: [], mode: TODO_MODE.ALL, }; const reducer = ( state = initialState, action: { type: string; payload: any; }, ) => { switch (action.type) { case ACTION_ADD_TODO: { const todo: ITodo = action.payload; return { ...state, list: [todo, ...state.list], }; } case ACTION_REMOVE_TODO: { const todoId: string = action.payload; return { ...state, list: state.list.filter((todo) => todo?.id !== todoId), }; } case ACTION_CHANGE_STATUS: { const todo: ITodo = action.payload; return { ...state, list: state.list.map((i) => (i?.id === todo?.id ? todo : i)), }; } case ACTION_TOGGLE_ALL_TODO: { return { ...state, list: state.list.map((todo) => ({ ...todo, status: TODO_STATUS.ACTIVE })), }; } case ACTION_CHANGE_MODE: { return { ...state, mode: action.payload, }; } default: return state; } }; export default reducer;
jayce-incognito/leapxpert-test-fe
src/module/Todo/Todo.tsx
/* eslint-disable jsx-a11y/no-autofocus */ import React from 'react'; import { v4 } from 'uuid'; import isEmpty from 'lodash/isEmpty'; import trim from 'lodash/trim'; import { useDispatch } from 'react-redux'; import styled from 'styled-components'; import { Input } from 'src/components/Core'; import { HeaderApp } from 'src/components/Header'; import { actionAddTodo } from './Todo.actions'; import { TODO_STATUS } from './Todo.constant'; import TodoList from './Todo.list'; import TodoGroupActions from './Todo.groupActions'; const Styled = styled.div``; const TodoBox = React.memo(() => { const dispatch = useDispatch(); const [todoVal, setTodoVal] = React.useState(''); const onChange = (e: React.ChangeEvent<HTMLInputElement>) => { setTodoVal(e.target.value); }; const onKeyDown = (e: React.KeyboardEvent<HTMLInputElement>) => { let value = trim(todoVal); if (e.key === 'Enter' && !isEmpty(todoVal)) { dispatch( actionAddTodo({ id: v4(), value, status: TODO_STATUS.ACTIVE, }), ); setTodoVal(''); } }; return ( <div className="input-container"> <Input type="text" onChange={onChange} value={todoVal} placeholder="Type something..." autoFocus onKeyDown={onKeyDown} /> </div> ); }); const Todo = () => { return ( <Styled> <HeaderApp /> <TodoBox /> <TodoList /> <TodoGroupActions /> </Styled> ); }; export default React.memo(Todo);
jayce-incognito/leapxpert-test-fe
src/module/Todo/Todo.styled.ts
<gh_stars>0 import styled from 'styled-components'; export const Styled = styled.div``;
jayce-incognito/leapxpert-test-fe
src/components/Core/Checkbox/Checkbox.tsx
<reponame>jayce-incognito/leapxpert-test-fe<filename>src/components/Core/Checkbox/Checkbox.tsx import React from 'react'; import styled from 'styled-components'; import PropTypes from 'prop-types'; import { IGlobalStyle } from 'src/styles'; interface IProps { onHandleChecked: () => any; label: string; checked: boolean; } const Styled = styled.button` .icon { margin-right: 5px; width: 15px; height: 15px; } .checkbox-label { line-height: 14px; color: ${(props: IGlobalStyle) => props.theme.text}; } `; const CheckboxVector = React.memo((props: any) => { return ( <svg width={15} height={15}> <path d="M12.147 14.567c1.59 0 2.41-.82 2.41-2.387V3.266c0-1.567-.82-2.388-2.41-2.388h-8.87c-1.582 0-2.41.813-2.41 2.388v8.914c0 1.567.828 2.387 2.41 2.387h8.87zm-.095-1.457h-8.68c-.673 0-1.047-.352-1.047-1.062v-8.65c0-.71.374-1.062 1.048-1.062h8.679c.666 0 1.047.352 1.047 1.062v8.65c0 .71-.38 1.062-1.047 1.062z" fill="#8A8A8E" fillRule="nonzero" {...props} /> </svg> ); }); const CheckedboxVector = React.memo((props: any) => { return ( <svg width={15} height={15}> <path d="M12.147 14.567c1.59 0 2.41-.82 2.41-2.387V3.266c0-1.567-.82-2.388-2.41-2.388h-8.87c-1.582 0-2.41.813-2.41 2.388v8.914c0 1.567.828 2.387 2.41 2.387h8.87zm-5.23-3.237c-.278 0-.505-.117-.71-.388L4.413 8.767a.826.826 0 01-.198-.52c0-.381.3-.689.681-.689.227 0 .403.08.593.322l1.407 1.78L9.92 4.826c.154-.256.367-.38.594-.38.373 0 .71.256.71.644 0 .168-.088.351-.19.513l-3.435 5.339a.782.782 0 01-.682.388z" fill="#000" fillRule="nonzero" {...props} /> </svg> ); }); const Checkbox = (props: IProps & React.ButtonHTMLAttributes<HTMLButtonElement>) => { const { onHandleChecked, label, checked } = props; return ( <Styled className="checkbox-container flex" onClick={onHandleChecked}> <div className="icon checkbox-icon"> {!checked ? <CheckboxVector className="icon-abs" /> : <CheckedboxVector className="icon-abs" />} </div> {label && <p className="checkbox-label fw-medium">{label}</p>} </Styled> ); }; Checkbox.propTypes = { onHandleChecked: PropTypes.func, }; export default Checkbox;
jayce-incognito/leapxpert-test-fe
src/components/Icons/OpenLink.tsx
import React from 'react'; import styled from 'styled-components'; interface IProps {} const Styled = styled.button` width: 14px; height: 15px; `; const OpenLinkVector = React.memo((props: any) => { return ( <svg width={14} height={15}> <path d="M1.059 13.158a.74.74 0 00.553-.237l8.728-8.719 1.45-1.643-.158 4.104v3.252c0 .413.36.8.79.8.423 0 .8-.36.8-.835l-.008-8.842c0-.5-.325-.852-.853-.852H3.52a.803.803 0 00-.827.8c0 .421.378.782.791.782h3.059l4.289-.141L9.197 3.06l-8.71 8.727a.8.8 0 00-.246.554c0 .422.378.817.818.817z" fill="#000" fillRule="nonzero" {...props} /> </svg> ); }); const OpenLink = (props: IProps & React.ButtonHTMLAttributes<HTMLButtonElement>) => { return ( <Styled className="icon" {...props}> <OpenLinkVector /> </Styled> ); }; export default OpenLink;
jayce-incognito/leapxpert-test-fe
src/module/Tooltip/Tooltip.tsx
<reponame>jayce-incognito/leapxpert-test-fe import React from 'react'; import styled from 'styled-components'; import isEmpty from 'lodash/isEmpty'; import { useSelector } from 'react-redux'; import { themeSelector } from 'src/module/Setting'; import { IGlobalStyle } from 'src/styles'; import enhance from './Tooltip.enhance'; import { ITooltipProps } from './Tooltip.interface'; const Styled = styled.div` position: absolute; z-index: 10000; display: flex; flex-direction: column; align-items: center; .custom-tooltip { background-color: ${(props: IGlobalStyle) => props.theme.tooltipBg}; color: ${(props: IGlobalStyle) => props.theme.tooltipText}; border-radius: 8px; padding: 6px 8px; } .arrow { content: ' '; position: absolute; bottom: 100%; /* At the top of the tooltip */ left: 50%; margin-left: -5px; border-width: 5px; border-style: solid; border-color: transparent transparent ${(props: IGlobalStyle) => props.theme.tooltipBg} transparent; } `; const Tooltip = (props: ITooltipProps) => { const { data, tooltipPosition } = props; const { text, className } = data; const theme = useSelector(themeSelector); if (isEmpty(tooltipPosition)) { return null; } return ( <Styled theme={theme} className={className} style={tooltipPosition}> <div className="custom-tooltip">{text}</div> <div className="arrow" /> </Styled> ); }; export default enhance(React.memo(Tooltip));
jayce-incognito/leapxpert-test-fe
src/services/cache.ts
export const caches: any = {}; export const cache = (key: string, data: any, expiredTime: number) => { caches[key] = { data, expiredTime: new Date().getTime() + expiredTime, }; }; export function getCache(key: string) { const cacheData = caches[key]; if (cacheData && cacheData.expiredTime > new Date().getTime()) { return cacheData.data; } return null; } export const clearCache = (key: string) => { if (!caches[key]) { return; } delete caches[key]; }; export const cachePromise = async (key: string, promiseFunc: () => Promise<any>, expiredTime?: number) => { const cachedData = getCache(key); if (cachedData !== null) { return cachedData; } const data = await promiseFunc(); cache(key, data, expiredTime || 10000); return data; };
jayce-incognito/leapxpert-test-fe
src/components/Icons/TrashBin.tsx
import React from 'react'; import styled from 'styled-components'; interface IProps {} const Styled = styled.button` min-width: 20px; height: 20px; `; const TrashVector = React.memo((props: any) => { return ( <svg width="1em" height="1em" viewBox="0 0 18 20" {...props}> <path d="M12.887 19.663c1.257 0 2.1-.817 2.162-2.074l.606-12.78h1.055c.36 0 .66-.307.66-.667 0-.36-.3-.66-.66-.66h-4.017V2.138c0-1.275-.826-2.048-2.18-2.048h-3.33c-1.354 0-2.18.773-2.18 2.048v1.344h-4a.67.67 0 00-.658.66c0 .369.307.668.659.668h1.055l.606 12.788c.062 1.256.897 2.065 2.162 2.065h8.06zm-1.591-16.18H6.4V2.225c0-.501.343-.827.87-.827h3.156c.527 0 .87.326.87.827v1.256zm1.45 14.853H4.95c-.5 0-.879-.378-.905-.897L3.43 4.81h10.81l-.571 12.63c-.026.528-.404.897-.923.897zm-6.495-1.503c.334 0 .554-.21.545-.519L6.532 6.91c-.009-.307-.237-.51-.553-.51-.334 0-.554.211-.545.519l.272 9.395c.009.317.22.519.545.519zm2.61 0c.334 0 .563-.21.563-.519V6.92c0-.308-.229-.519-.563-.519-.334 0-.571.211-.571.519v9.395c0 .308.237.519.571.519zm2.602 0c.316 0 .536-.202.545-.519l.272-9.395c.01-.308-.22-.519-.553-.519-.308 0-.537.203-.545.519l-.264 9.395c-.009.308.21.519.545.519z" fill="#8A8A8E" fillRule="nonzero" /> </svg> ); }); const TrashBin = (props: IProps & React.ButtonHTMLAttributes<HTMLButtonElement>) => { return ( <Styled className="icon trash-bin-icon" {...props}> <TrashVector /> </Styled> ); }; export default TrashBin;