Commit 3219f81a authored by tom's avatar tom

style tabs

parent a5e29dcf
...@@ -8,6 +8,7 @@ import iconFile from './icons/file.svg'; ...@@ -8,6 +8,7 @@ import iconFile from './icons/file.svg';
import iconFolderOpen from './icons/folder-open.svg'; import iconFolderOpen from './icons/folder-open.svg';
import iconFolder from './icons/folder.svg'; import iconFolder from './icons/folder.svg';
import iconSolidity from './icons/solidity.svg'; import iconSolidity from './icons/solidity.svg';
import useColors from './utils/useColors';
interface Props { interface Props {
tree: FileTree; tree: FileTree;
...@@ -26,6 +27,7 @@ const CodeEditorFileTree = ({ tree, level = 0, onItemClick, isCollapsed }: Props ...@@ -26,6 +27,7 @@ const CodeEditorFileTree = ({ tree, level = 0, onItemClick, isCollapsed }: Props
}, },
}; };
const rowHoverBgColor = useColorModeValue('blackAlpha.200', 'whiteAlpha.200'); const rowHoverBgColor = useColorModeValue('blackAlpha.200', 'whiteAlpha.200');
const colors = useColors();
return ( return (
<Accordion allowMultiple defaultIndex={ isCollapsed ? undefined : tree.map((item, index) => index) } reduceMotion> <Accordion allowMultiple defaultIndex={ isCollapsed ? undefined : tree.map((item, index) => index) } reduceMotion>
...@@ -48,7 +50,7 @@ const CodeEditorFileTree = ({ tree, level = 0, onItemClick, isCollapsed }: Props ...@@ -48,7 +50,7 @@ const CodeEditorFileTree = ({ tree, level = 0, onItemClick, isCollapsed }: Props
h="22px" h="22px"
transitionDuration="0" transitionDuration="0"
> >
<AccordionIcon transform={ isExpanded ? 'rotate(0deg)' : 'rotate(-90deg)' } boxSize="16px" color="#616161"/> <AccordionIcon transform={ isExpanded ? 'rotate(0deg)' : 'rotate(-90deg)' } boxSize="16px" color={ colors.buttons.color }/>
<Icon as={ isExpanded ? iconFolderOpen : iconFolder } boxSize="16px" mr="4px"/> <Icon as={ isExpanded ? iconFolderOpen : iconFolder } boxSize="16px" mr="4px"/>
{ leafName } { leafName }
</AccordionButton> </AccordionButton>
......
...@@ -7,6 +7,7 @@ import useDebounce from 'lib/hooks/useDebounce'; ...@@ -7,6 +7,7 @@ import useDebounce from 'lib/hooks/useDebounce';
import CodeEditorSearchSection from './CodeEditorSearchSection'; import CodeEditorSearchSection from './CodeEditorSearchSection';
import CoderEditorCollapseButton from './CoderEditorCollapseButton'; import CoderEditorCollapseButton from './CoderEditorCollapseButton';
import useColors from './utils/useColors';
interface Props { interface Props {
data: Array<File>; data: Array<File>;
...@@ -74,7 +75,7 @@ const CodeEditorSearch = ({ monaco, data, onFileSelect, isInputStuck }: Props) = ...@@ -74,7 +75,7 @@ const CodeEditorSearch = ({ monaco, data, onFileSelect, isInputStuck }: Props) =
const inputColor = useColorModeValue('rgb(97, 97, 97)', 'rgb(204, 204, 204)'); const inputColor = useColorModeValue('rgb(97, 97, 97)', 'rgb(204, 204, 204)');
const inputBgColor = useColorModeValue('white', 'rgb(60, 60, 60)'); const inputBgColor = useColorModeValue('white', 'rgb(60, 60, 60)');
const inputFocusBorderColor = useColorModeValue('#0090f1', '#007fd4'); const inputFocusBorderColor = useColorModeValue('#0090f1', '#007fd4');
const bgColor = useColorModeValue('#eee', '#222'); const colors = useColors();
return ( return (
<Box> <Box>
...@@ -84,7 +85,7 @@ const CodeEditorSearch = ({ monaco, data, onFileSelect, isInputStuck }: Props) = ...@@ -84,7 +85,7 @@ const CodeEditorSearch = ({ monaco, data, onFileSelect, isInputStuck }: Props) =
isDisabled={ searchResults.length === 0 } isDisabled={ searchResults.length === 0 }
isCollapsed={ expandedSections.length === 0 } isCollapsed={ expandedSections.length === 0 }
/> />
<Box px={ 2 } position="sticky" top="35px" left="0" zIndex="2" bgColor={ bgColor } pb="8px" boxShadow={ isInputStuck ? 'md' : 'none' }> <Box px={ 2 } position="sticky" top="35px" left="0" zIndex="2" bgColor={ colors.panels.bgColor } pb="8px" boxShadow={ isInputStuck ? 'md' : 'none' }>
<Input <Input
size="xs" size="xs"
onChange={ handleSearchTermChange } onChange={ handleSearchTermChange }
......
...@@ -7,6 +7,7 @@ import CodeEditorSearchResultItem from './CodeEditorSearchResultItem'; ...@@ -7,6 +7,7 @@ import CodeEditorSearchResultItem from './CodeEditorSearchResultItem';
import iconFile from './icons/file.svg'; import iconFile from './icons/file.svg';
import iconSolidity from './icons/solidity.svg'; import iconSolidity from './icons/solidity.svg';
import getFileName from './utils/getFileName'; import getFileName from './utils/getFileName';
import useColors from './utils/useColors';
interface Props { interface Props {
data: SearchResult; data: SearchResult;
...@@ -27,6 +28,7 @@ const CodeEditorSearchSection = ({ data, onItemClick }: Props) => { ...@@ -27,6 +28,7 @@ const CodeEditorSearchSection = ({ data, onItemClick }: Props) => {
const icon = /.sol|.yul|.vy$/.test(fileName) ? iconSolidity : iconFile; const icon = /.sol|.yul|.vy$/.test(fileName) ? iconSolidity : iconFile;
const badgeBgColor = useColorModeValue('#c4c4c4', '#4d4d4d'); const badgeBgColor = useColorModeValue('#c4c4c4', '#4d4d4d');
const colors = useColors();
return ( return (
<AccordionItem borderWidth="0px" _last={{ borderBottomWidth: '0px' }} > <AccordionItem borderWidth="0px" _last={{ borderBottomWidth: '0px' }} >
...@@ -41,7 +43,7 @@ const CodeEditorSearchSection = ({ data, onItemClick }: Props) => { ...@@ -41,7 +43,7 @@ const CodeEditorSearchSection = ({ data, onItemClick }: Props) => {
lineHeight="22px" lineHeight="22px"
alignItems="center" alignItems="center"
> >
<AccordionIcon transform={ isExpanded ? 'rotate(0deg)' : 'rotate(-90deg)' } boxSize="16px" color="#616161"/> <AccordionIcon transform={ isExpanded ? 'rotate(0deg)' : 'rotate(-90deg)' } boxSize="16px" color={ colors.buttons.color }/>
<Icon as={ icon } boxSize="16px" mr="4px"/> <Icon as={ icon } boxSize="16px" mr="4px"/>
<span>{ fileName }</span> <span>{ fileName }</span>
<Box className="monaco-count-badge" ml="auto" bgColor={ badgeBgColor }>{ data.matches.length }</Box> <Box className="monaco-count-badge" ml="auto" bgColor={ badgeBgColor }>{ data.matches.length }</Box>
......
...@@ -7,6 +7,7 @@ import type { File, Monaco } from './types'; ...@@ -7,6 +7,7 @@ import type { File, Monaco } from './types';
import CodeEditorFileExplorer from './CodeEditorFileExplorer'; import CodeEditorFileExplorer from './CodeEditorFileExplorer';
import CodeEditorSearch from './CodeEditorSearch'; import CodeEditorSearch from './CodeEditorSearch';
import useColors from './utils/useColors';
interface Props { interface Props {
monaco: Monaco | undefined; monaco: Monaco | undefined;
...@@ -32,21 +33,21 @@ const CodeEditorSideBar = ({ onFileSelect, data, monaco }: Props) => { ...@@ -32,21 +33,21 @@ const CodeEditorSideBar = ({ onFileSelect, data, monaco }: Props) => {
letterSpacing: 0.3, letterSpacing: 0.3,
}; };
const bgColor = useColorModeValue('#eee', '#222'); const colors = useColors();
const handleScrollThrottled = React.useRef(_throttle((event: React.SyntheticEvent) => { const handleScrollThrottled = React.useRef(_throttle((event: React.SyntheticEvent) => {
setIsStuck((event.target as HTMLDivElement).scrollTop > 0); setIsStuck((event.target as HTMLDivElement).scrollTop > 0);
}, 100)); }, 100));
return ( return (
<Box w="250px" flexShrink={ 0 } bgColor={ bgColor } fontSize="13px" overflowY="scroll" onScroll={ handleScrollThrottled.current } pb="22px"> <Box w="250px" flexShrink={ 0 } bgColor={ colors.panels.bgColor } fontSize="13px" overflowY="scroll" onScroll={ handleScrollThrottled.current } pb="22px">
<Tabs isLazy lazyBehavior="keepMounted" variant="unstyled" size="13px"> <Tabs isLazy lazyBehavior="keepMounted" variant="unstyled" size="13px">
<TabList <TabList
columnGap={ 3 } columnGap={ 3 }
position="sticky" position="sticky"
top={ 0 } top={ 0 }
left={ 0 } left={ 0 }
bgColor={ bgColor } bgColor={ colors.panels.bgColor }
zIndex="1" zIndex="1"
px={ 2 } px={ 2 }
boxShadow={ isStuck ? 'md' : 'none' } boxShadow={ isStuck ? 'md' : 'none' }
......
import { Flex, IconButton, chakra } from '@chakra-ui/react'; import { Flex, IconButton, Icon, chakra, useColorModeValue } from '@chakra-ui/react';
import React from 'react'; import React from 'react';
import iconCross from 'icons/cross.svg'; import iconCross from 'icons/cross.svg';
import iconFile from './icons/file.svg';
import iconSolidity from './icons/solidity.svg';
import getFilePathParts from './utils/getFilePathParts'; import getFilePathParts from './utils/getFilePathParts';
import * as themes from './utils/themes';
import useColors from './utils/useColors';
interface Props { interface Props {
isActive?: boolean; isActive?: boolean;
path: string; path: string;
...@@ -16,6 +19,7 @@ interface Props { ...@@ -16,6 +19,7 @@ interface Props {
const CodeEditorTab = ({ isActive, path, onClick, onClose, isCloseDisabled, tabsPathChunks }: Props) => { const CodeEditorTab = ({ isActive, path, onClick, onClose, isCloseDisabled, tabsPathChunks }: Props) => {
const [ fileName, folderName ] = getFilePathParts(path, tabsPathChunks); const [ fileName, folderName ] = getFilePathParts(path, tabsPathChunks);
const colors = useColors();
const handleClick = React.useCallback(() => { const handleClick = React.useCallback(() => {
onClick(path); onClick(path);
...@@ -26,41 +30,50 @@ const CodeEditorTab = ({ isActive, path, onClick, onClose, isCloseDisabled, tabs ...@@ -26,41 +30,50 @@ const CodeEditorTab = ({ isActive, path, onClick, onClose, isCloseDisabled, tabs
!isCloseDisabled && onClose(path); !isCloseDisabled && onClose(path);
}, [ isCloseDisabled, onClose, path ]); }, [ isCloseDisabled, onClose, path ]);
const bgColor = useColorModeValue(themes.light.colors['editor.background'], themes.dark.colors['editor.background']);
const bgColorInactive = useColorModeValue('rgb(236, 236, 236)', 'rgb(45, 45, 45)');
const icon = /.sol|.yul|.vy$/.test(fileName) ? iconSolidity : iconFile;
const borderColorInactive = useColorModeValue('rgb(243, 243, 243)', 'rgb(37, 37, 38)');
return ( return (
<Flex <Flex
py={ 1 } pl="10px"
pl={ 3 } pr={ isActive ? '4px' : '28px' }
pr={ isActive ? 0 : 5 } fontSize="13px"
fontSize="sm" lineHeight="34px"
lineHeight={ 6 } bgColor={ isActive ? bgColor : bgColorInactive }
borderRightWidth="1px" borderRightWidth="1px"
borderRightColor="divider" borderRightColor={ borderColorInactive }
borderBottomWidth="1px" borderBottomWidth="1px"
borderBottomColor={ isActive ? 'deeppink' : 'divider' } borderBottomColor={ isActive ? 'transparent' : borderColorInactive }
color={ isActive ? 'black' : 'gray.600' } color={ isActive ? 'black' : 'gray.600' }
alignItems="center" alignItems="center"
fontWeight={ 500 } fontWeight={ 500 }
mb="-1px"
cursor="pointer" cursor="pointer"
onClick={ handleClick } onClick={ handleClick }
_hover={{ _hover={{
pr: '0', pr: '4px',
svg: { svg: {
display: 'block', display: 'block',
}, },
}} }}
> >
<Icon as={ icon } boxSize="16px" mr="4px"/>
<span>{ fileName }</span> <span>{ fileName }</span>
{ folderName && <chakra.span fontSize="xs" color="text_secondary" ml={ 1 }>{ folderName[0] === '.' ? '' : '...' }{ folderName }</chakra.span> } { folderName && <chakra.span fontSize="xs" color="text_secondary" ml={ 1 }>{ folderName[0] === '.' ? '' : '...' }{ folderName }</chakra.span> }
<IconButton <IconButton
as={ iconCross } as={ iconCross }
boxSize={ 5 } boxSize={ 5 }
ml="4px"
p="2px" p="2px"
variant="unstyled" variant="unstyled"
aria-label="close" aria-label="close"
onClick={ handleClose } onClick={ handleClose }
isDisabled={ isCloseDisabled } isDisabled={ isCloseDisabled }
display={ isActive ? 'block' : 'none' } display={ isActive ? 'block' : 'none' }
borderRadius="sm"
color={ colors.buttons.color }
_hover={{ bgColor: colors.buttons.bgColorHover }}
/> />
</Flex> </Flex>
); );
......
...@@ -2,6 +2,7 @@ import { Flex } from '@chakra-ui/react'; ...@@ -2,6 +2,7 @@ import { Flex } from '@chakra-ui/react';
import React from 'react'; import React from 'react';
import CodeEditorTab from './CodeEditorTab'; import CodeEditorTab from './CodeEditorTab';
import useColors from './utils/useColors';
interface Props { interface Props {
tabs: Array<string>; tabs: Array<string>;
...@@ -11,15 +12,15 @@ interface Props { ...@@ -11,15 +12,15 @@ interface Props {
} }
const CodeEditorTabs = ({ tabs, activeTab, onTabSelect, onTabClose }: Props) => { const CodeEditorTabs = ({ tabs, activeTab, onTabSelect, onTabClose }: Props) => {
const colors = useColors();
const tabsPathChunks = React.useMemo(() => { const tabsPathChunks = React.useMemo(() => {
return tabs.map((tab) => tab.split('/')); return tabs.map((tab) => tab.split('/'));
}, [ tabs ]); }, [ tabs ]);
return ( return (
<Flex <Flex
bgColor="lightblue" bgColor={ colors.panels.bgColor }
borderBottomWidth="1px"
borderColor="divider"
flexWrap="wrap" flexWrap="wrap"
> >
{ tabs.map((tab) => ( { tabs.map((tab) => (
......
import { Tooltip, Box, useColorModeValue } from '@chakra-ui/react'; import { Tooltip, Box } from '@chakra-ui/react';
import React from 'react'; import React from 'react';
import useColors from './utils/useColors';
interface Props { interface Props {
onClick: () => void; onClick: () => void;
label: string; label: string;
...@@ -9,7 +11,7 @@ interface Props { ...@@ -9,7 +11,7 @@ interface Props {
} }
const CoderEditorCollapseButton = ({ onClick, label, isDisabled, isCollapsed }: Props) => { const CoderEditorCollapseButton = ({ onClick, label, isDisabled, isCollapsed }: Props) => {
const hoverBgColor = useColorModeValue('rgba(184, 184, 184, 0.31)', 'rgba(90, 93, 94, 0.31)'); const colors = useColors();
return ( return (
<Tooltip label={ label } isDisabled={ isDisabled }> <Tooltip label={ label } isDisabled={ isDisabled }>
<Box <Box
...@@ -26,7 +28,7 @@ const CoderEditorCollapseButton = ({ onClick, label, isDisabled, isCollapsed }: ...@@ -26,7 +28,7 @@ const CoderEditorCollapseButton = ({ onClick, label, isDisabled, isCollapsed }:
content: isCollapsed ? '"\\eb95"' : '"\\eac5"', content: isCollapsed ? '"\\eb95"' : '"\\eac5"',
}} }}
_hover={{ _hover={{
bgColor: hoverBgColor, bgColor: colors.buttons.bgColorHover,
}} }}
onClick={ onClick } onClick={ onClick }
cursor="pointer" cursor="pointer"
......
export default function getFilePathParts(path: string, tabsPathChunks: Array<Array<string>>) { export default function getFilePathParts(path: string, tabsPathChunks: Array<Array<string>>): [string, string | undefined] {
const chunks = path.split('/'); const chunks = path.split('/');
const fileName = chunks[chunks.length - 1]; const fileName = chunks[chunks.length - 1];
const folderName = getFolderName(chunks, tabsPathChunks); const folderName = getFolderName(chunks, tabsPathChunks);
......
import { useColorModeValue } from '@chakra-ui/react';
export default function useColors() {
return {
panels: {
bgColor: useColorModeValue('#eee', '#222'),
},
buttons: {
bgColorHover: useColorModeValue('rgba(184, 184, 184, 0.31)', 'rgba(90, 93, 94, 0.31)'),
color: '#616161',
},
};
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment