Skip to content

Commit

Permalink
Merge pull request #218 from kubeshop/catalinhoha/refactor/styling-ch…
Browse files Browse the repository at this point in the history
…anges

styling changes
  • Loading branch information
devcatalin authored Aug 10, 2021
2 parents 375b51b + 74ad567 commit d0d001d
Show file tree
Hide file tree
Showing 3 changed files with 50 additions and 25 deletions.
59 changes: 37 additions & 22 deletions src/App.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -64,8 +64,28 @@ const StyledContent = styled(Content)`
overflow-y: clip;
`;

const iconStyle = {
fontSize: 25,
const MenuIcon = (props: {
icon: React.ElementType;
active: boolean;
isSelected: boolean;
style?: React.CSSProperties;
}) => {
const {icon: IconComponent, active, isSelected, style: customStyle = {}} = props;
const [isHovered, setIsHovered] = useState<boolean>(false);

const style = {
...customStyle,
fontSize: 25,
color: Colors.grey7,
};

if (isHovered || (active && isSelected)) {
style.color = Colors.grey400;
}

return (
<IconComponent style={style} onMouseEnter={() => setIsHovered(true)} onMouseLeave={() => setIsHovered(false)} />
);
};

const iconMenuWidth = 45;
Expand Down Expand Up @@ -140,12 +160,11 @@ const App = () => {
type="text"
onClick={() => setActivePanes('left', 'file-explorer')}
icon={
<FolderOpenOutlined
style={{
...iconStyle,
color: leftMenuSelection === 'file-explorer' ? Colors.whitePure : Colors.grey7,
marginLeft: 4,
}}
<MenuIcon
style={{marginLeft: 4}}
icon={FolderOpenOutlined}
active={leftActive}
isSelected={leftMenuSelection === 'file-explorer'}
/>
}
/>
Expand All @@ -156,11 +175,10 @@ const App = () => {
type="text"
onClick={() => setActivePanes('left', 'cluster-explorer')}
icon={
<ClusterOutlined
style={{
...iconStyle,
color: leftMenuSelection === 'cluster-explorer' ? Colors.whitePure : Colors.grey7,
}}
<MenuIcon
icon={ClusterOutlined}
active={leftActive}
isSelected={leftMenuSelection === 'cluster-explorer'}
/>
}
/>
Expand All @@ -186,7 +204,7 @@ const App = () => {
</>
}
hideLeft={!leftActive}
nav={<NavigatorPane />}
nav={<NavigatorPane windowHeight={size.height} />}
editor={<ActionsPane contentHeight={contentHeight} />}
right={
<>
Expand All @@ -208,11 +226,10 @@ const App = () => {
type="text"
onClick={() => setActivePanes('right', 'graph')}
icon={
<ApartmentOutlined
style={{
...iconStyle,
color: rightMenuSelection === 'graph' ? Colors.whitePure : Colors.grey7,
}}
<MenuIcon
icon={ApartmentOutlined}
active={rightActive}
isSelected={rightMenuSelection === 'graph'}
/>
}
style={{display: featureJson.ShowGraphView ? 'inline' : 'none'}}
Expand All @@ -223,9 +240,7 @@ const App = () => {
type="text"
onClick={() => setActivePanes('right', 'logs')}
icon={
<CodeOutlined
style={{...iconStyle, color: rightMenuSelection === 'logs' ? Colors.whitePure : Colors.grey7}}
/>
<MenuIcon icon={CodeOutlined} active={rightActive} isSelected={rightMenuSelection === 'logs'} />
}
/>
</Space>
Expand Down
4 changes: 3 additions & 1 deletion src/components/organisms/FileTreePane/FileTreePane.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -233,6 +233,8 @@ const BrowseButton = styled(Button)`
margin-top: 1px;
`;

const FILE_TREE_HEIGHT_OFFSET = 122;

const FileTreePane = (props: {windowHeight: number | undefined}) => {
const {windowHeight} = props;
const dispatch = useAppDispatch();
Expand Down Expand Up @@ -405,7 +407,7 @@ const FileTreePane = (props: {windowHeight: number | undefined}) => {
) : tree ? (
<StyledTreeDirectoryTree
// height is needed to enable Tree's virtual scroll ToDo: Do constants based on the hights of app title and pane title, or get height of parent.
height={windowHeight && windowHeight > 122 ? windowHeight - 122 : 0}
height={windowHeight && windowHeight > FILE_TREE_HEIGHT_OFFSET ? windowHeight - FILE_TREE_HEIGHT_OFFSET : 0}
onSelect={onSelect}
treeData={[tree]}
ref={treeRef}
Expand Down
12 changes: 10 additions & 2 deletions src/components/organisms/NavigatorPane/NavigatorPane.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,10 @@ const SectionHeader = (props: {
);
};

const NavigatorPane = () => {
const NAVIGATOR_HEIGHT_OFFSET = 112;

const NavigatorPane = (props: {windowHeight: number}) => {
const {windowHeight} = props;
const previewLoader = useAppSelector(state => state.main.previewLoader);
const uiState = useAppSelector(state => state.ui);
const helmCharts = useSelector(selectHelmCharts);
Expand Down Expand Up @@ -150,7 +153,12 @@ const NavigatorPane = () => {
</MonoPaneTitle>
</MonoPaneTitleCol>
</TitleRow>
<NavigatorPaneContainer>
<NavigatorPaneContainer
style={{
height:
windowHeight && windowHeight > NAVIGATOR_HEIGHT_OFFSET ? windowHeight - NAVIGATOR_HEIGHT_OFFSET : '100%',
}}
>
{uiState.isFolderLoading ? (
<StyledSkeleton active />
) : (
Expand Down

0 comments on commit d0d001d

Please sign in to comment.