Skip to content

Commit

Permalink
Remove shadow scroll
Browse files Browse the repository at this point in the history
  • Loading branch information
hanbyul-here committed Oct 4, 2023
1 parent 49d04c7 commit 403b887
Show file tree
Hide file tree
Showing 7 changed files with 24 additions and 36 deletions.
21 changes: 5 additions & 16 deletions app/scripts/components/common/dropdown-scrollable.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import React, { forwardRef, ReactNode } from 'react';
import React, { forwardRef } from 'react';
import styled from 'styled-components';
import { glsp } from '@devseed-ui/theme-provider';
import {
Expand All @@ -9,14 +9,14 @@ import {
DropTitle
} from '@devseed-ui/dropdown';

import { ShadowScrollbarImproved as ShadowScrollbar } from '$components/common/shadow-scrollbar-improved';

/**
* Override Dropdown styles to play well with the shadow scrollbar.
*/
const DropdownWithScroll = styled(Dropdown)`
padding: 0;
overflow: hidden;
max-height: 320px;
overflow-y: auto;
${DropTitle} {
margin: 0;
Expand All @@ -28,23 +28,12 @@ const DropdownWithScroll = styled(Dropdown)`
}
`;

const shadowScrollbarProps = {
autoHeight: true,
autoHeightMax: 320
};

interface DropdownScrollableProps extends DropdownProps {
children?: ReactNode;
}

export default forwardRef<DropdownRef, DropdownScrollableProps>(
export default forwardRef<DropdownRef, DropdownProps>(
function DropdownScrollable(props, ref) {
const { children, ...rest } = props;
return (
<DropdownWithScroll ref={ref} {...rest}>
<ShadowScrollbar scrollbarsProps={shadowScrollbarProps}>
{children}
</ShadowScrollbar>
{children}
</DropdownWithScroll>
);
}
Expand Down
10 changes: 2 additions & 8 deletions app/scripts/components/common/mapbox/layer-legend.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -252,17 +252,11 @@ export function LayerLegend(
)}
renderBody={() => (
<LegendBody>
<ShadowScrollbar
scrollbarsProps={{
autoHeight: true,
autoHeightMin: 32,
autoHeightMax: 120
}}
>

<div className='scroll-inner'>
{description || <p>No info available for this layer.</p>}
</div>
</ShadowScrollbar>

</LegendBody>
)}
/>
Expand Down
6 changes: 2 additions & 4 deletions app/scripts/components/common/mapbox/map-options/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,6 @@ import { MapOptionsProps } from './types';
import { projectionsList } from './utils';
import { BASEMAP_STYLES } from './basemaps';

import { ShadowScrollbarImproved as ShadowScrollbar } from '$components/common/shadow-scrollbar-improved';

const DropHeader = styled.div`
padding: ${glsp()};
box-shadow: inset 0 -1px 0 0 ${themeVal('color.base-100a')};
Expand Down Expand Up @@ -143,7 +141,7 @@ function MapOptions(props: MapOptionsProps) {
<DropTitle>Map options</DropTitle>
</DropHeader>
<DropBody>
<ShadowScrollbar scrollbarsProps={shadowScrollbarProps}>

<ContentGroup>
<ContentGroupHeader>
<ContentGroupTitle>Style</ContentGroupTitle>
Expand Down Expand Up @@ -258,7 +256,7 @@ function MapOptions(props: MapOptionsProps) {
</DropMenu>
</ContentGroupBody>
</ContentGroup>
</ShadowScrollbar>

</DropBody>
</MapOptionsDropdown>
);
Expand Down
15 changes: 11 additions & 4 deletions app/scripts/components/common/page-header.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -214,6 +214,9 @@ const GlobalNavInner = styled.div`
const GlobalNavHeader = styled.div`
padding: ${variableGlsp(1)};
box-shadow: inset 0 -1px 0 0 ${themeVal('color.surface-200a')};
${media.largeUp`
display: none;
`}
`;

const GlobalNavTitle = styled(Heading).attrs({
Expand All @@ -225,16 +228,16 @@ const GlobalNavTitle = styled(Heading).attrs({

export const GlobalNavActions = styled.div`
align-self: start;
${media.largeUp`
display: none;
`}
`;

export const GlobalNavToggle = styled(Button)`
z-index: 2000;
`;

const GlobalNavBody = styled(ShadowScrollbar).attrs({
topShadowVariation: 'dark',
bottomShadowVariation: 'dark'
})`
const GlobalNavBody = styled.div`
display: flex;
flex: 1;
Expand Down Expand Up @@ -339,6 +342,10 @@ function PageHeader() {

useEffect(() => {
// Close global nav when media query changes.
// NOTE: isMediumDown is returning document.body's width, not the whole window width
// which conflicts with how mediaquery decides the width.
// JSX element susing isMediumDown is also protected with css logic because of this.
// ex. Look at GlobalNavActions
if (!isMediumDown) setGlobalNavRevealed(false);
}, [isMediumDown]);

Expand Down
3 changes: 1 addition & 2 deletions app/scripts/components/common/page-local-nav.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@ import {
import { reveal } from '@devseed-ui/animation';
import { Overline } from '@devseed-ui/typography';
import { DropMenu, DropMenuItem } from '@devseed-ui/dropdown';
import { ShadowScrollbar } from '@devseed-ui/shadow-scrollbar';

import DropdownScrollable from './dropdown-scrollable';

Expand Down Expand Up @@ -57,7 +56,7 @@ const LocalBreadcrumb = styled.ol`
}
`;

const NavBlock = styled(ShadowScrollbar)`
const NavBlock = styled.div`
display: flex;
align-items: center;
flex-flow: row nowrap;
Expand Down
3 changes: 2 additions & 1 deletion app/scripts/components/common/shadow-scrollbar-improved.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
import React, { useCallback, useEffect, useState } from 'react';
import { ShadowScrollbar } from '@devseed-ui/shadow-scrollbar';

// Moving away from this component because of the issue
// https://github.com/NASA-IMPACT/veda-ui/issues/682#issuecomment-1747334303
export const ShadowScrollbarImproved = React.forwardRef<
HTMLDivElement,
React.ComponentProps<typeof ShadowScrollbar>
Expand Down Expand Up @@ -29,7 +31,6 @@ export const ShadowScrollbarImproved = React.forwardRef<
...(scrollbarsProps ?? {}),
autoHide
};

return (
<ShadowScrollbar
ref={ref}
Expand Down
2 changes: 1 addition & 1 deletion app/scripts/styles/panel.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ export const PanelToggle = styled(Button)`
left: calc(100% + ${variableGlsp()});
`;

export const PanelBody = styled(ShadowScrollbar)`
export const PanelBody = styled.div`
display: flex;
flex-direction: column;
flex-grow: 1;
Expand Down

0 comments on commit 403b887

Please sign in to comment.