-
Notifications
You must be signed in to change notification settings - Fork 51
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
12 changed files
with
211 additions
and
18 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
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
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,46 @@ | ||
import classNames from 'classnames'; | ||
import noop from 'lodash/noop'; | ||
import { PropsWithChildren } from 'react'; | ||
import { CommonProps } from '../type'; | ||
|
||
export interface Option { | ||
label: string; | ||
value: any; | ||
} | ||
|
||
interface Props extends CommonProps { | ||
options: Option[]; | ||
onChange?(v: Option): void; | ||
optionStyle?: string; | ||
} | ||
|
||
function Component(props: PropsWithChildren<Props>) { | ||
const { children, optionStyle, options = [], onChange = noop } = props; | ||
return ( | ||
<div className="dropdown"> | ||
<label tabIndex={0}>{children}</label> | ||
<ul | ||
tabIndex={0} | ||
className={classNames( | ||
'dropdown-content menu p-2 shadow bg-base-100 rounded-box w-52', | ||
optionStyle | ||
)} | ||
> | ||
{options.map((option) => { | ||
return ( | ||
<li | ||
key={option.value} | ||
onClick={() => { | ||
onChange(option); | ||
}} | ||
> | ||
<a>{option.label}</a> | ||
</li> | ||
); | ||
})} | ||
</ul> | ||
</div> | ||
); | ||
} | ||
|
||
export default Component; |
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 |
---|---|---|
@@ -1,3 +1,10 @@ | ||
import React from 'react'; | ||
|
||
export type ISize = 'lg' | 'md' | 'sm' | 'xs'; | ||
|
||
export type Itype = 'primary' | 'secondary' | 'accent'; | ||
|
||
export interface CommonProps { | ||
className?: string; | ||
style?: React.CSSProperties; | ||
} |
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,25 @@ | ||
import { useEffect } from 'react'; | ||
import { Terminal } from 'xterm'; | ||
|
||
function Component() { | ||
useEffect(() => { | ||
var term = new Terminal({ rows: 10 }); | ||
term.open(document.querySelector('#terminal') as HTMLElement); | ||
term.write( | ||
`\u001b[01m\u001b[Kcode.c:\u001b[m\u001b[K In function '\u001b[01m\u001b[Kint main()\u001b[m\u001b[K':\r\n\u001b[01m\u001b[Kcode.c:6:1:\u001b[m\u001b[K \u001b[01;31m\u001b[Kerror: \u001b[m\u001b[Kexpected '\u001b[01m\u001b[K;\u001b[m\u001b[K' before '\u001b[01m\u001b[K}\u001b[m\u001b[K' token\r\n }\r\n\u001b[01;32m\u001b[K ^\u001b[m\u001b[K\r\n` + | ||
`\u001b[01m\u001b[Kcode.c:\u001b[m\u001b[K In function '\u001b[01m\u001b[Kint main()\u001b[m\u001b[K':\r\n\u001b[01m\u001b[Kcode.c:6:1:\u001b[m\u001b[K \u001b[01;31m\u001b[Kerror: \u001b[m\u001b[Kexpected '\u001b[01m\u001b[K;\u001b[m\u001b[K' before '\u001b[01m\u001b[K}\u001b[m\u001b[K' token\r\n }\r\n\u001b[01;32m\u001b[K ^\u001b[m\u001b[K\r\n` + | ||
`\u001b[01m\u001b[Kcode.c:\u001b[m\u001b[K In function '\u001b[01m\u001b[Kint main()\u001b[m\u001b[K':\r\n\u001b[01m\u001b[Kcode.c:6:1:\u001b[m\u001b[K \u001b[01;31m\u001b[Kerror: \u001b[m\u001b[Kexpected '\u001b[01m\u001b[K;\u001b[m\u001b[K' before '\u001b[01m\u001b[K}\u001b[m\u001b[K' token\r\n }\r\n\u001b[01;32m\u001b[K ^\u001b[m\u001b[K\r\n` + | ||
`\u001b[01m\u001b[Kcode.c:\u001b[m\u001b[K In function '\u001b[01m\u001b[Kint main()\u001b[m\u001b[K':\r\n\u001b[01m\u001b[Kcode.c:6:1:\u001b[m\u001b[K \u001b[01;31m\u001b[Kerror: \u001b[m\u001b[Kexpected '\u001b[01m\u001b[K;\u001b[m\u001b[K' before '\u001b[01m\u001b[K}\u001b[m\u001b[K' token\r\n }\r\n\u001b[01;32m\u001b[K ^\u001b[m\u001b[K\r\n` + | ||
`\u001b[01m\u001b[Kcode.c:\u001b[m\u001b[K In function '\u001b[01m\u001b[Kint main()\u001b[m\u001b[K':\r\n\u001b[01m\u001b[Kcode.c:6:1:\u001b[m\u001b[K \u001b[01;31m\u001b[Kerror: \u001b[m\u001b[Kexpected '\u001b[01m\u001b[K;\u001b[m\u001b[K' before '\u001b[01m\u001b[K}\u001b[m\u001b[K' token\r\n }\r\n\u001b[01;32m\u001b[K ^\u001b[m\u001b[K\r\n` + | ||
`\u001b[01m\u001b[Kcode.c:\u001b[m\u001b[K In function '\u001b[01m\u001b[Kint main()\u001b[m\u001b[K':\r\n\u001b[01m\u001b[Kcode.c:6:1:\u001b[m\u001b[K \u001b[01;31m\u001b[Kerror: \u001b[m\u001b[Kexpected '\u001b[01m\u001b[K;\u001b[m\u001b[K' before '\u001b[01m\u001b[K}\u001b[m\u001b[K' token\r\n }\r\n\u001b[01;32m\u001b[K ^\u001b[m\u001b[K\r\n` + | ||
`\u001b[01m\u001b[Kcode.c:\u001b[m\u001b[K In function '\u001b[01m\u001b[Kint main()\u001b[m\u001b[K':\r\n\u001b[01m\u001b[Kcode.c:6:1:\u001b[m\u001b[K \u001b[01;31m\u001b[Kerror: \u001b[m\u001b[Kexpected '\u001b[01m\u001b[K;\u001b[m\u001b[K' before '\u001b[01m\u001b[K}\u001b[m\u001b[K' token\r\n }\r\n\u001b[01;32m\u001b[K ^\u001b[m\u001b[K\r\n` | ||
); | ||
return () => { | ||
term.dispose(); | ||
}; | ||
}, []); | ||
|
||
return <div id="terminal"></div>; | ||
} | ||
|
||
export default Component; |
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
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