-
-
Notifications
You must be signed in to change notification settings - Fork 70
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
16 changed files
with
245 additions
and
40 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
# These are supported funding model platforms | ||
|
||
github: # Replace with up to 4 GitHub Sponsors-enabled usernames e.g., [user1, user2] | ||
patreon: # Replace with a single Patreon username | ||
open_collective: # Replace with a single Open Collective username | ||
ko_fi: # Replace with a single Ko-fi username | ||
tidelift: # Replace with a single Tidelift platform-name/package-name e.g., npm/babel | ||
community_bridge: # Replace with a single Community Bridge project-name e.g., cloud-foundry | ||
liberapay: # Replace with a single Liberapay username | ||
issuehunt: # Replace with a single IssueHunt username | ||
otechie: # Replace with a single Otechie username | ||
lfx_crowdfunding: # Replace with a single LFX Crowdfunding project-name e.g., cloud-foundry | ||
custom: ['https://github.com/heluxjs/helux/issues/141', 'https://tnfe.gtimg.com/image/5a2u6arzpo_1705217036205.png'] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
/** | ||
* | ||
* 工具栏组件, | ||
* | ||
* | ||
* | ||
*/ | ||
import React, { useCallback } from "react"; | ||
import { codeContext, setCodeContext } from "./codeContext"; | ||
import { IconButton } from "./icons/IconButton"; | ||
import localforage from 'localforage'; | ||
|
||
|
||
export const Tools: React.FC = () => { | ||
|
||
const saveCode = useCallback(() => { | ||
localforage.setItem(`helux_code_${codeContext.key}`, codeContext.code, (err) => { | ||
if (err) { | ||
console.error(err) | ||
} else { | ||
console.info('code is saved') | ||
} | ||
}) | ||
}, []) | ||
|
||
const resetCode = useCallback(() => { | ||
localforage.removeItem(`helux_code_${codeContext.key}`, (err) => { | ||
if (!err) { | ||
setCodeContext(draft => { draft.code = '' }) | ||
} | ||
}) | ||
}, []) | ||
|
||
return <div style={{ | ||
position: "absolute", | ||
display: "flex", | ||
flexDirection: "column", | ||
padding: "8px", | ||
boxSizing: "border-box", | ||
backgroundColor: "transparent", | ||
left: "50%", | ||
top: "36px", | ||
width: "60px", | ||
right: "10px", | ||
}}> | ||
<IconButton name="save" title="保存代码" onClick={() => saveCode()} /> | ||
<IconButton name="reset" title="恢复代码" onClick={() => resetCode()} /> | ||
</div> | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
import { share } from "helux"; | ||
|
||
const [codeContext,setCodeContext,codeCtx] = share<{ | ||
key:string, | ||
code:string | ||
}>({key:"",code:"",}) | ||
|
||
export { | ||
codeContext, | ||
setCodeContext, | ||
codeCtx | ||
} |
22 changes: 22 additions & 0 deletions
22
docs/docs/playground/demos/Playground/icons/IconButton.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
import { ReactNode,ButtonHTMLAttributes } from "react" | ||
import { ResetIcon } from "./Reset" | ||
import { SaveIcon } from "./Save" | ||
|
||
export interface IconButtonProps extends ButtonHTMLAttributes<HTMLButtonElement> { | ||
name:"save" | 'reset' | ||
} | ||
|
||
const icons:Record<string,ReactNode> = { | ||
save:<SaveIcon/>, | ||
reset:<ResetIcon/> | ||
} | ||
export const IconButton:React.FC<IconButtonProps> = (props)=>{ | ||
return <button style={{ | ||
margin:"4px", | ||
width:"32px", | ||
height:"32px", | ||
padding:"8px", | ||
cursor:"pointer", | ||
borderRadius:"24px" | ||
}} {...props} type="button">{icons[props.name]}</button> | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
import { SVGProps } from "react"; | ||
|
||
export function ResetIcon(props: SVGProps<SVGSVGElement>) { | ||
return ( | ||
<svg xmlns="http://www.w3.org/2000/svg" width="1em" height="1em" viewBox="0 0 24 24" {...props}><path fill="none" stroke="currentColor" strokeWidth="2" d="M20 8c-1.403-2.96-4.463-5-8-5a9 9 0 1 0 0 18a9 9 0 0 0 9-9m0-9v6h-6"></path></svg> | ||
) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
import { SVGProps } from "react"; | ||
|
||
export function SaveIcon(props: SVGProps<SVGSVGElement>) { | ||
return ( | ||
<svg xmlns="http://www.w3.org/2000/svg" width="1em" height="1em" viewBox="0 0 24 24" {...props}><path fill="currentColor" d="M23.681 6.158L17.843.32a1.093 1.093 0 0 0-.771-.32H1.092C.489 0 .001.489.001 1.091v21.817c0 .603.489 1.091 1.091 1.091h21.817c.603 0 1.091-.489 1.091-1.091V6.928c0-.301-.122-.574-.32-.771zM6.549 2.182h6.546v5.819H6.546zm0 19.635v-5.818h10.905v5.818zm15.273 0h-2.185v-6.908c0-.603-.489-1.091-1.091-1.091H5.455c-.603 0-1.091.489-1.091 1.091v6.909H2.182V2.181h2.182V9.09c0 .603.489 1.091 1.091 1.091h8.728c.603 0 1.091-.489 1.091-1.091V2.181h1.344l5.199 5.199z"></path></svg> | ||
) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.