-
Notifications
You must be signed in to change notification settings - Fork 24
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #1 from jaipaljadeja/help/fullscreen
Refactor of Fullscreen Implentation and Footer theme changes
- Loading branch information
Showing
14 changed files
with
291 additions
and
293 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
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,53 @@ | ||
import { useContext } from 'react' | ||
|
||
import cn from 'classnames' | ||
|
||
import { AppUiContext } from '../../context/appUiContext' | ||
import { CairoVMApiContext } from '../../context/cairoVMApiContext' | ||
import KBarButton from '../KBar/Button' | ||
import ThemeSelector from '../ThemeSelector' | ||
import ToggleFullScreen from '../ToggleFullScreen' | ||
import ToggleThreeColumnLayout from '../ToggleThreeColumnLayout' | ||
|
||
function EditorFooter() { | ||
const { cairoLangCompilerVersion } = useContext(CairoVMApiContext) | ||
const { isFullScreen } = useContext(AppUiContext) | ||
return ( | ||
<div | ||
className={cn( | ||
'px-5 bg-gray-100 dark:bg-black-700 border-t border-gray-200 dark:border-black-500 text-xs h-[42px] items-center text-gray-600 ml-auto flex justify-between', | ||
!isFullScreen && 'rounded-b-lg', | ||
)} | ||
> | ||
<span> | ||
{cairoLangCompilerVersion !== '' | ||
? `Cairo Compiler v${cairoLangCompilerVersion}` | ||
: ' '} | ||
</span> | ||
|
||
{isFullScreen && ( | ||
<div className="flex items-center justify-end divide-x divide-gray-200 dark:divide-black-500"> | ||
<span className="pr-4"> | ||
Made with ❤️ by{' '} | ||
<a | ||
className="underline font-medium" | ||
href="https://walnut.dev" | ||
target="_blank" | ||
rel="noreferrer" | ||
> | ||
Walnut | ||
</a> | ||
</span> | ||
<div className="items-center flex"> | ||
<KBarButton /> | ||
<ToggleFullScreen /> | ||
<ToggleThreeColumnLayout /> | ||
<ThemeSelector /> | ||
</div> | ||
</div> | ||
)} | ||
</div> | ||
) | ||
} | ||
|
||
export default EditorFooter |
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,87 @@ | ||
import React, { useId } from 'react' | ||
|
||
import { RiFileCodeLine } from '@remixicon/react' | ||
import cn from 'classnames' | ||
import Select, { | ||
components, | ||
DropdownIndicatorProps, | ||
StylesConfig, | ||
GroupBase, | ||
} from 'react-select' | ||
|
||
import { Button } from '../ui' | ||
|
||
import { Examples, CairoExampleNames } from './examples' | ||
|
||
type SelectOption = { | ||
value: number | ||
label: string | ||
} | ||
|
||
type Props = { | ||
onExampleChange: (option: SelectOption | null) => void | ||
} | ||
|
||
const examplesOptions = Examples.Cairo.map((_, i) => ({ | ||
value: i, | ||
label: CairoExampleNames[i], | ||
})) | ||
|
||
function ExampleSelector({ onExampleChange }: Props) { | ||
return ( | ||
<Select | ||
onChange={onExampleChange} | ||
options={examplesOptions} | ||
components={{ | ||
DropdownIndicator, | ||
}} | ||
controlShouldRenderValue={false} | ||
classNamePrefix="select" | ||
styles={reactSelectStyles} | ||
menuPlacement="top" | ||
isSearchable={false} | ||
instanceId={useId()} | ||
/> | ||
) | ||
} | ||
|
||
export default ExampleSelector | ||
|
||
const reactSelectStyles: StylesConfig< | ||
SelectOption, | ||
false, | ||
GroupBase<SelectOption> | ||
> = { | ||
// as we dont want to show value field in react-select | ||
// and just want to show an icon, but input field takes some space | ||
// so we hide the valueContainer with css properties | ||
// Question: Why not remove the ValueContainer completely from 'components' prop in react-select? | ||
// Ans: react-select needs a valuefield | ||
// as many features like click outside to close drop down etc depends on it | ||
// so we just add display none (it doesn't hurt) | ||
valueContainer: (styles) => ({ | ||
...styles, | ||
width: '0', | ||
opacity: 0, | ||
padding: '0 !important', | ||
}), | ||
} | ||
|
||
const DropdownIndicator = (props: DropdownIndicatorProps<SelectOption>) => { | ||
return ( | ||
<components.DropdownIndicator {...props}> | ||
<Button | ||
transparent | ||
padded={false} | ||
tooltip="Cairo Examples" | ||
tooltipId="cairo-examples" | ||
className={cn( | ||
'p-2 text-indigo-500 hover:text-indigo-600 focus:outline-none', | ||
props.selectProps.menuIsOpen ? 'bg-black-900/5 dark:bg-white/5' : '', | ||
)} | ||
> | ||
<RiFileCodeLine size={16} /> | ||
</Button> | ||
</components.DropdownIndicator> | ||
) | ||
} |
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.