react-feather#Settings TypeScript Examples
The following examples show how to use
react-feather#Settings.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: index.tsx From forward.swaps with GNU General Public License v3.0 | 6 votes |
StyledMenuIcon = styled(Settings)`
height: 20px;
width: 20px;
> * {
stroke: ${({ theme }) => theme.text2};
}
:hover {
opacity: 0.7;
}
`
Example #2
Source File: index.tsx From cuiswap with GNU General Public License v3.0 | 5 votes |
StyledMenuIcon = styled(Settings)`
height: 20px;
width: 20px;
> * {
stroke: ${({ theme }) => theme.text1};
}
`
Example #3
Source File: index.tsx From cheeseswap-interface with GNU General Public License v3.0 | 5 votes |
StyledMenuIcon = styled(Settings)`
height: 20px;
width: 20px;
> * {
stroke: ${({ theme }) => theme.colors.text1};
}
`
Example #4
Source File: index.tsx From dyp with Do What The F*ck You Want To Public License | 5 votes |
StyledMenuIcon = styled(Settings)`
height: 20px;
width: 20px;
> * {
stroke: ${({ theme }) => theme.text1};
}
`
Example #5
Source File: SideBar.tsx From bee-dashboard with BSD 3-Clause "New" or "Revised" License | 5 votes |
navBarItems = [
{
label: 'Info',
path: ROUTES.INFO,
icon: Home,
},
{
label: 'Files',
path: ROUTES.UPLOAD,
icon: FileText,
},
{
label: 'Feeds',
path: ROUTES.FEEDS,
icon: Bookmark,
},
{
label: 'Stamps',
path: ROUTES.STAMPS,
icon: Layers,
},
{
label: 'Accounting',
path: ROUTES.ACCOUNTING,
icon: DollarSign,
},
{
label: 'Settings',
path: ROUTES.SETTINGS,
icon: Settings,
},
{
label: 'Account',
path: ROUTES.WALLET,
icon: Briefcase,
},
{
label: 'Gift Wallets',
path: ROUTES.GIFT_CODES,
icon: Gift,
},
]
Example #6
Source File: routes.ts From Aragorn with MIT License | 5 votes |
routes: Routes = [
{
name: 'dashboard',
path: '/',
component: Dashboard,
icon: Grid
},
{
name: 'uploader',
path: '/uploader',
component: Uploader,
icon: Package
},
{
name: 'profile',
path: '/profile/:id?',
component: Profile,
icon: Box
},
{
name: 'fileManage',
path: '/fileManage/:id?',
component: FileManage,
icon: Server
},
{
name: 'upload',
icon: Upload
},
{
name: 'about',
path: '/about',
component: About,
icon: Info,
isFooter: true
},
{
name: 'setting',
path: '/setting',
component: Setting,
icon: Settings,
isFooter: true
}
]
Example #7
Source File: index.tsx From sushiswap-exchange with GNU General Public License v3.0 | 5 votes |
StyledMenuIcon = styled(Settings)`
height: 20px;
width: 20px;
> * {
stroke: ${({ theme }) => theme.text1};
}
`
Example #8
Source File: index.tsx From luaswap-interface with GNU General Public License v3.0 | 5 votes |
StyledMenuIcon = styled(Settings)`
height: 20px;
width: 20px;
> * {
stroke: ${({ theme }) => theme.text1};
}
`
Example #9
Source File: index.tsx From tweet2image with MIT License | 4 votes |
export function MainApp({
GYAZO_CLIENT_ID,
currentUrl,
}: {
GYAZO_CLIENT_ID: string
currentUrl: string
}) {
const [loading, setLoading] = useState(false)
const initialFormState = useInitialFormState()
const [formState, dispatch] = useReducer(formReducer, initialFormState)
const [blob, setBlob] = useState<string | null>(null)
const [loaded, setLoaded] = useState(false)
const [isGyazoUploading, setIsGyazoUploading] = useState(false)
const [gyazoRedirect, setGyazoRedirect] = useState<string | null>(null)
const [gyazoSnippet, setGyazoSnippet] = useState<string | null>(null)
const formRef = useRef<HTMLFormElement>(null)
const proceededUrl = useRef<string | null>(null)
const tweetId = useRef<string | null>(null)
const hash = useRef<string | null>(null)
const isNowEditing = useRef<boolean>(false)
const retryCount = useRef<number>(0)
const { gyazoClientId, userGyazoClientId, setGyazoClientId } =
useGyazoClientIdState(GYAZO_CLIENT_ID)
const { editing, addTaskOnEditFinished, handleEditingStateChange } =
useEditingState()
const getChangedSetting = () => {
const settings: { [key: string]: string | number } = {}
if (formState.lang !== "ja") settings["lang"] = formState.lang
if (formState.timezone !== 9) settings["tz"] = formState.timezone
if (formState.theme !== "light") settings["theme"] = formState.theme
if (formState.scale !== 2) settings["scale"] = formState.scale
return settings
}
const getImageUrl = () => {
const settings = getChangedSetting()
const url = new URL(currentUrl)
url.pathname = `${tweetId.current}.${formState.imageFormat}`
if (!!Object.keys(settings).length) {
url.search = querystring.stringify(settings)
}
return url.href
}
const getScrapboxSnippet = () => {
return `[${getImageUrl()} ${proceededUrl.current}]`
}
const onSubmit = async () => {
await handleSubmitForm()
}
const handleSubmitForm = async () => {
if (loading) return
const { url, imageFormat, theme, lang, scale, timezone: tz } = formState
if (url.length === 0) return
const m = url.match(/(twitter.com\/(.+)\/status\/)?(\d+)/)
if (!m) {
toast.error("The format of the URL is invalid.")
return
}
tweetId.current = m[3]
const stat = [tweetId.current, imageFormat, theme, lang, scale, tz].join("")
if (hash.current === stat) return
hash.current = stat
proceededUrl.current = `https://twitter.com/${m[2] || "twitter"}/status/${
tweetId.current
}`
setLoading(true)
setGyazoRedirect(null)
try {
const url = new URL(currentUrl)
url.pathname = `${tweetId.current}.${imageFormat}`
let imageUrl = url.href
const settings = getChangedSetting()
if (!!Object.keys(settings).length) {
url.search = querystring.stringify(settings)
imageUrl = url.href
}
const r = await fetch(imageUrl)
if (!r.ok) {
switch (r.status) {
case 404:
toast.error("No tweets found.")
break
default:
toast.error(`An error has occurred: ${r.statusText}`)
hash.current = null
setTimeout(async () => {
if (retryCount.current < 2) {
retryCount.current++
if (formRef.current?.requestSubmit) {
formRef.current.requestSubmit()
} else {
await handleSubmitForm()
}
}
}, 1000)
break
}
setLoading(false)
return
}
retryCount.current = 0
const blob = await r.blob()
const blobUrl = URL.createObjectURL(blob)
setBlob(blobUrl)
setLoading(false)
setLoaded(true)
} catch (error) {
toast.error(`An error has occurred.`)
setLoading(false)
return
}
}
useEffect(() => {
let handle: number | undefined
let remove: (() => void) | undefined
if (editing) {
remove = addTaskOnEditFinished(handleSubmitForm)
} else {
handle = window.setTimeout(() => handleSubmitForm(), 1000)
}
return () => {
window.clearTimeout(handle)
remove?.()
}
}, [formState, editing, addTaskOnEditFinished])
useEffect(() => {
const parsed = new URLSearchParams(location.hash.slice(1))
if (0 < Array.from(parsed.entries()).length) {
if (isNowEditing.current || loading) return
handleSubmitForm()
/*if (tweetInput.current.form.requestSubmit) {
setTimeout(() => tweetInput.current.form.requestSubmit(), 0)
} else {
handleSubmitForm()
}*/
}
}, [])
const tweetUploadToGyazo = async () => {
if (!blob) {
return
}
setIsGyazoUploading(true)
toast.info("Uploading to Gyazo...")
try {
const r = await fetch(blob)
const imageData = await r.blob()
const base64Img: Blob = await new Promise((res, rej) => {
const reader = new FileReader()
reader.onerror = rej
reader.onload = () => {
res(reader.result as any as Blob)
}
reader.readAsDataURL(imageData)
})
const formData = new FormData()
formData.append("client_id", gyazoClientId)
formData.append("referer_url", proceededUrl.current || "")
formData.append("image_url", base64Img)
const easyAuth = await fetch(
`https://upload.gyazo.com/api/upload/easy_auth`,
{
method: "POST",
mode: "cors",
body: formData,
}
)
const uploadResult = await easyAuth.json()
window.open(uploadResult.get_image_url, "pop", "width=800, height=480")
setGyazoRedirect(uploadResult.get_image_url)
setGyazoSnippet(`[ ${proceededUrl.current}]`)
} catch (e) {
console.error(e)
toast.error("Failed to upload to gyazo")
} finally {
setIsGyazoUploading(false)
}
}
return (
<div className="min-h-screen w-full flex flex-col text-gray-800">
<ToastContainer
position={"top-left"}
autoClose={2500}
closeOnClick={true}
transition={Slide}
/>
<div className="flex-1">
<div className="container mx-auto max-w-screen-md p-4">
<div className="m-1 mt-4 mb-2 text-2xl flex justify-between items-center relative">
<h1>tweet2image</h1>
<details style={{ fontSize: 0 }}>
<summary className="text-gray-600 flex items-center">
<Settings aria-label="設定" size={20} />
</summary>
<div className="absolute bg-white shadow mt-8 right-0 top-0 z-20">
<div className="text-sm p-4 leading-relaxed">
<h1 className="text-lg pb-2">設定</h1>
<h2 className="text-base pb-2">Gyazo Client ID</h2>
<input
type="text"
placeholder={GYAZO_CLIENT_ID}
className="appearance-none block w-full border border-gray-200 rounded py-3 px-4 mb-3 leading-tight focus:outline-none focus:bg-white focus:border-gray-500 bg-gray-100 text-gray-700"
value={userGyazoClientId || ""}
onChange={(e) => setGyazoClientId(e.target.value)}
></input>
</div>
</div>
</details>
</div>
<hr />
<div className="mx-1">
<div className="mt-2">
<Form
ref={formRef}
state={formState}
dispatch={dispatch}
disabled={loading}
onEditingStateChange={handleEditingStateChange}
onSubmit={onSubmit}
/>
</div>
<div className="mt-4">
{loaded && proceededUrl.current ? (
<a href={proceededUrl.current} target="_blank" rel="noopener">
<div className="relative w-full text-center bg-gray-300 rounded-t">
{blob && <img className="w-full" src={blob} />}
<div className="absolute loading-center">
<div className="h-full flex items-center justify-center">
<div
className={`loading ${
loading ? "opacity-100" : "opacity-0"
}`}
></div>
</div>
</div>
</div>
</a>
) : (
<div className="h-full w-full flex-none bg-cover text-center bg-gray-300 rounded-t bg-center placeholder-cover">
<div className="flex items-center justify-center">
<div
className={`loading ${
loading ? "opacity-100" : "opacity-0"
}`}
></div>
</div>
</div>
)}
</div>
{tweetId.current && (
<div className="mt-2">
<label className="block tracking-wide text-gray-600 text-sm mb-2">
Image Url
</label>
<div className="flex flex-wrap items-stretch w-full mb-4 relative">
<input
type="text"
className="flex-shrink flex-grow leading-normal w-px flex-1 h-10 rounded rounded-r-none px-3 relative bg-gray-200 text-gray-700 border border-gray-200"
value={getImageUrl()}
readOnly
/>
<div className="flex -mr-px">
<button
className="flex items-center leading-normal bg-grey-lighter rounded rounded-l-none border border-l-0 border-grey-light px-3 whitespace-no-wrap text-grey-dark text-sm"
onClick={async () => {
try {
if (navigator.clipboard) {
await navigator.clipboard.writeText(getImageUrl())
toast.info("copied.")
}
} catch (e) {
console.error(e)
}
}}
>
Copy
</button>
</div>
</div>
<label className="block tracking-wide text-gray-600 text-sm mb-2">
Scrapbox Snippet
</label>
<div className="flex flex-wrap items-stretch w-full mb-4 relative">
<input
type="text"
className="flex-shrink flex-grow leading-normal w-px flex-1 h-10 rounded rounded-r-none px-3 relative bg-gray-200 text-gray-700 border border-gray-200"
value={getScrapboxSnippet()}
readOnly
/>
<div className="flex -mr-px">
<button
className="flex items-center leading-normal bg-grey-lighter rounded rounded-l-none border border-l-0 border-grey-light px-3 whitespace-no-wrap text-grey-dark text-sm"
onClick={async () => {
try {
if (navigator.clipboard) {
await navigator.clipboard.writeText(
getScrapboxSnippet()
)
toast.info("copied.")
}
} catch (e) {
console.error(e)
}
}}
>
Copy
</button>
</div>
</div>
<div className="mx-auto mt-6 mb-2">
<button
className={`flex items-center leading-normal bg-gray-lighter rounded border border-indigo-200 p-2 whitespace-no-wrap text-grey-dark text-sm mx-auto ${
(loading ||
isGyazoUploading ||
!!gyazoRedirect ||
!gyazoClientId) &&
"bg-gray-200 text-gray-400"
}`}
disabled={
loading ||
isGyazoUploading ||
!!gyazoRedirect ||
!gyazoClientId
}
onClick={tweetUploadToGyazo}
>
Upload to Gyazo?
</button>
{gyazoRedirect && (
<div>
<label className="block tracking-wide text-gray-600 text-sm my-2">
Scrapbox Snippet
</label>
<div className="flex flex-wrap items-stretch w-full mb-1 relative">
<input
type="text"
className="flex-shrink flex-grow leading-normal w-px flex-1 h-10 rounded rounded-r-none px-3 relative bg-gray-100 text-gray-700 border border-gray-200"
value={gyazoSnippet || ""}
onChange={(e) => setGyazoSnippet(e.target.value)}
/>
<div className="flex -mr-px">
<button
className="flex items-center leading-normal bg-grey-lighter rounded rounded-l-none border border-l-0 border-grey-light px-3 whitespace-no-wrap text-grey-dark text-sm"
onClick={async () => {
try {
if (navigator.clipboard && gyazoSnippet) {
await navigator.clipboard.writeText(
gyazoSnippet
)
toast.info("copied.")
}
} catch (e) {
console.error(e)
}
}}
>
Copy
</button>
</div>
</div>
<p className="text-sm text-gray-600">
To complete this snippet, paste{" "}
<a
className="text-blue-400"
href={gyazoRedirect}
target="_blank"
>
the URL of the Gyazo page
</a>{" "}
opened on the popup to in the text box above.
</p>
</div>
)}
</div>
</div>
)}
</div>
</div>
</div>
<div className="container max-w-screen-md mx-auto">
<hr />
<div className="flex justify-end text-xs p-4">
<div className="text-right">
<span>
tweet2image /
<a
className="text-blue-400"
target="_blank"
href="https://github.com/ci7lus/tweet2image"
rel="noopener"
>
code & bug report
</a>
/
</span>
<span className="inline-block">
Animation from
<a
className="text-blue-400"
href="https://github.com/potato4d/preloaders"
target="_blank"
rel="noopener"
>
potato4d/preloaders
</a>
</span>
</div>
</div>
</div>
</div>
)
}
Example #10
Source File: ManageLists.tsx From limit-orders-lib with GNU General Public License v3.0 | 4 votes |
ListRow = memo(function ListRow({ listUrl }: { listUrl: string }) {
const listsByUrl = useSelector<AppState, AppState["glists"]["byUrl"]>(
(state) => state.glists.byUrl
);
const dispatch = useDispatch<AppDispatch>();
const { current: list, pendingUpdate: pending } = listsByUrl[listUrl];
const theme = useTheme();
const listColor = useListColor(list?.logoURI);
const isActive = useIsListActive(listUrl);
const [open, toggle] = useToggle(false);
const node = useRef<HTMLDivElement>();
const [referenceElement, setReferenceElement] = useState<HTMLDivElement>();
const [popperElement, setPopperElement] = useState<HTMLDivElement>();
const { styles, attributes } = usePopper(referenceElement, popperElement, {
placement: "auto",
strategy: "fixed",
modifiers: [{ name: "offset", options: { offset: [8, 8] } }],
});
useOnClickOutside(node, open ? toggle : undefined);
const handleAcceptListUpdate = useCallback(() => {
if (!pending) return;
dispatch(acceptListUpdate(listUrl));
}, [dispatch, listUrl, pending]);
const handleRemoveList = useCallback(() => {
if (
window.prompt(
`Please confirm you would like to remove this list by typing REMOVE`
) === `REMOVE`
) {
dispatch(removeList(listUrl));
}
}, [dispatch, listUrl]);
const handleEnableList = useCallback(() => {
dispatch(enableList(listUrl));
}, [dispatch, listUrl]);
const handleDisableList = useCallback(() => {
dispatch(disableList(listUrl));
}, [dispatch, listUrl]);
if (!list) return null;
return (
<RowWrapper
active={isActive}
bgColor={listColor}
key={listUrl}
id={listUrlRowHTMLId(listUrl)}
>
{list.logoURI ? (
<ListLogo
size="40px"
style={{ marginRight: "1rem" }}
logoURI={list.logoURI}
alt={`${list.name} list logo`}
/>
) : (
<div style={{ width: "24px", height: "24px", marginRight: "1rem" }} />
)}
<Column style={{ flex: "1" }}>
<Row>
<StyledTitleText active={isActive}>{list.name}</StyledTitleText>
</Row>
<RowFixed mt="4px">
<StyledListUrlText active={isActive} mr="6px">
{list.tokens.length} tokens
</StyledListUrlText>
<StyledMenu ref={node as any}>
<ButtonEmpty onClick={toggle} ref={setReferenceElement} padding="0">
<Settings stroke={isActive ? theme.bg1 : theme.text1} size={12} />
</ButtonEmpty>
{open && (
<PopoverContainer
show={true}
ref={setPopperElement as any}
style={styles.popper}
{...attributes.popper}
>
<div>{list && listVersionLabel(list.version)}</div>
<SeparatorDark />
<ExternalLink
href={`https://tokenlists.org/token-list?url=${listUrl}`}
>
View list
</ExternalLink>
<UnpaddedLinkStyledButton
onClick={handleRemoveList}
disabled={Object.keys(listsByUrl).length === 1}
>
Remove list
</UnpaddedLinkStyledButton>
{pending && (
<UnpaddedLinkStyledButton onClick={handleAcceptListUpdate}>
Update list
</UnpaddedLinkStyledButton>
)}
</PopoverContainer>
)}
</StyledMenu>
</RowFixed>
</Column>
<ListToggle
isActive={isActive}
bgColor={listColor}
toggle={() => {
isActive ? handleDisableList() : handleEnableList();
}}
/>
</RowWrapper>
);
})
Example #11
Source File: ManageLists.tsx From forward.swaps with GNU General Public License v3.0 | 4 votes |
ListRow = memo(function ListRow({ listUrl }: { listUrl: string }) {
const listsByUrl = useSelector<AppState, AppState['lists']['byUrl']>(state => state.lists.byUrl)
const dispatch = useDispatch<AppDispatch>()
const { current: list, pendingUpdate: pending } = listsByUrl[listUrl]
const theme = useTheme()
const listColor = useListColor(list?.logoURI)
const isActive = useIsListActive(listUrl)
const [open, toggle] = useToggle(false)
const node = useRef<HTMLDivElement>()
const [referenceElement, setReferenceElement] = useState<HTMLDivElement>()
const [popperElement, setPopperElement] = useState<HTMLDivElement>()
const { styles, attributes } = usePopper(referenceElement, popperElement, {
placement: 'auto',
strategy: 'fixed',
modifiers: [{ name: 'offset', options: { offset: [8, 8] } }]
})
useOnClickOutside(node, open ? toggle : undefined)
const handleAcceptListUpdate = useCallback(() => {
if (!pending) return
ReactGA.event({
category: 'Lists',
action: 'Update List from List Select',
label: listUrl
})
dispatch(acceptListUpdate(listUrl))
}, [dispatch, listUrl, pending])
const handleRemoveList = useCallback(() => {
ReactGA.event({
category: 'Lists',
action: 'Start Remove List',
label: listUrl
})
if (window.prompt(`Please confirm you would like to remove this list by typing REMOVE`) === `REMOVE`) {
ReactGA.event({
category: 'Lists',
action: 'Confirm Remove List',
label: listUrl
})
dispatch(removeList(listUrl))
}
}, [dispatch, listUrl])
const handleEnableList = useCallback(() => {
ReactGA.event({
category: 'Lists',
action: 'Enable List',
label: listUrl
})
dispatch(enableList(listUrl))
}, [dispatch, listUrl])
const handleDisableList = useCallback(() => {
ReactGA.event({
category: 'Lists',
action: 'Disable List',
label: listUrl
})
dispatch(disableList(listUrl))
}, [dispatch, listUrl])
if (!list) return null
return (
<RowWrapper active={isActive} bgColor={listColor} key={listUrl} id={listUrlRowHTMLId(listUrl)}>
{list.logoURI ? (
<ListLogo size="40px" style={{ marginRight: '1rem' }} logoURI={list.logoURI} alt={`${list.name} list logo`} />
) : (
<div style={{ width: '24px', height: '24px', marginRight: '1rem' }} />
)}
<Column style={{ flex: '1' }}>
<Row>
<StyledTitleText active={isActive}>{list.name}</StyledTitleText>
</Row>
<RowFixed mt="4px">
<StyledListUrlText active={isActive} mr="6px">
{list.tokens.length} tokens
</StyledListUrlText>
<StyledMenu ref={node as any}>
<ButtonEmpty onClick={toggle} ref={setReferenceElement} padding="0">
<Settings stroke={isActive ? theme.bg1 : theme.text1} size={12} />
</ButtonEmpty>
{open && (
<PopoverContainer show={true} ref={setPopperElement as any} style={styles.popper} {...attributes.popper}>
<div>{list && listVersionLabel(list.version)}</div>
<SeparatorDark />
<ExternalLink href={`https://tokenlists.org/token-list?url=${listUrl}`}>View list</ExternalLink>
<UnpaddedLinkStyledButton onClick={handleRemoveList} disabled={Object.keys(listsByUrl).length === 1}>
Remove list
</UnpaddedLinkStyledButton>
{pending && (
<UnpaddedLinkStyledButton onClick={handleAcceptListUpdate}>Update list</UnpaddedLinkStyledButton>
)}
</PopoverContainer>
)}
</StyledMenu>
</RowFixed>
</Column>
<ListToggle
isActive={isActive}
bgColor={listColor}
toggle={() => {
isActive ? handleDisableList() : handleEnableList()
}}
/>
</RowWrapper>
)
})