Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

More-ui-changes #669

Merged
merged 2 commits into from
Apr 10, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 16 additions & 1 deletion src/components/checkbox/checkbox-component.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,19 @@ import PropTypes from 'prop-types';

import cx from 'classnames';

import { HALF_EARTH_FUTURE_TILE_LAYER } from 'constants/layers-slugs';

import styles from './checkbox-styles.module.scss';

function Checkbox({ option, onChange, checked, theme, className, disabled }) {
function Checkbox({
option,
onChange,
checked,
theme,
className,
disabled,
showProgress,
}) {
return (
<div
key={option.value}
Expand Down Expand Up @@ -35,6 +45,11 @@ function Checkbox({ option, onChange, checked, theme, className, disabled }) {
/>
)}
</label>
{option.value === HALF_EARTH_FUTURE_TILE_LAYER && showProgress && (
<div className={styles.progressBar}>
<div className={`${styles.circle} ${styles.border}`} />
</div>
)}
</div>
);
}
Expand Down
31 changes: 31 additions & 0 deletions src/components/checkbox/checkbox-styles.module.scss
Original file line number Diff line number Diff line change
Expand Up @@ -59,3 +59,34 @@ input[type="checkbox"] {
height: 10px;
width: 10px;
}

.progressBar {
position: relative;
width: 20px;
height: 20px;
}

.circle {
height: 100%;
right: 0px;
position: absolute;
border: solid 5px $alto;
border-top-color: $robins-egg-blue;
border-radius: 50%;
}

.border {
width: 100%;
transform: rotate(135deg);
animation: spin 1.3s steps(2) .2s infinite;
-webkit-animation: spin 1.3s linear infinite;
}

@keyframes spin {
0% {
transform: rotate(0deg);
}
100% {
transform: rotate(360deg);
}
}
2 changes: 2 additions & 0 deletions src/components/layer-toggle/checkbox-type/component.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ function CheckboxType({
onOpacityClick,
onBringToBackClick,
onBringToFrontClick,
showProgress,
}) {
return (
<div
Expand All @@ -32,6 +33,7 @@ function CheckboxType({
checked={!disabled && isChecked}
onChange={onChange}
className={styles.labelStyles}
showProgress={showProgress}
/>
</div>
{isChecked && !disabled && (
Expand Down
2 changes: 2 additions & 0 deletions src/components/layer-toggle/component.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ function LayerToggleComponent({
handleBringToBackClick,
handleBringToFrontClick,
className,
showProgress,
}) {
return type === 'radio' ? (
<div
Expand Down Expand Up @@ -75,6 +76,7 @@ function LayerToggleComponent({
onOpacityClick={handleOpacityClick}
onBringToBackClick={handleBringToBackClick}
onBringToFrontClick={handleBringToFrontClick}
showProgress={showProgress}
/>
</div>
);
Expand Down
2 changes: 1 addition & 1 deletion src/components/radio-button/radio-button-component.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ function RadioButton({
'visually-hidden': hideLabel,
})}
style={{
'margin-top': Array.isArray(option.name) ? '-4px' : '',
marginTop: Array.isArray(option.name) ? '-4px' : '',
}}
>
{option && option.name}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -99,9 +99,9 @@ function SidebarCard({
const isCustom = contextualData?.isCustom;

const underProtectionPercentage = isCustom
? contextualData?.percentage
: contextualData?.protectionPercentage;
const spi = contextualData?.SPI;
? parseFloat(contextualData?.percentage)
: parseFloat(contextualData?.protectionPercentage);
const spi = parseFloat(contextualData?.SPI);
return (
<SidebarCardWrapper className={styles.cardWrapper}>
<div>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ import {
HIGHER_AREA_SIZE_LIMIT,
CLEAR_SELECTIONS,
} from 'constants/analyze-areas-constants';
import { HALF_EARTH_FUTURE_TILE_LAYER } from 'constants/layers-slugs';
import { SEARCH_TYPES } from 'constants/search-location-constants';

import radioTheme from 'styles/themes/radio-theme.module.scss';
Expand Down Expand Up @@ -53,6 +54,7 @@ function AnalyzeAreasCardComponent({
sketchTooltipType,
updatedGeometry,
setUpdatedGeometry,
showProgress,
}) {
const t = useT();
const locale = useLocale();
Expand Down Expand Up @@ -147,6 +149,12 @@ function AnalyzeAreasCardComponent({
theme={radioTheme}
/>
)}
{option.slug === HALF_EARTH_FUTURE_TILE_LAYER &&
showProgress && (
<div className={styles.progressBar}>
<div className={`${styles.circle} ${styles.border}`} />
</div>
)}
</div>
);
})}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -120,6 +120,8 @@ function AnalyzeAreasContainer(props) {
const [selectedOption, setSelectedOption] = useState(
precalculatedAOIOptions[0]
);
const [showProgress, setShowProgress] = useState(false);
const [isFirstLoad, setIsFirstLoad] = useState(true);
const [sketchWidgetMode, setSketchWidgetMode] = useState('create');
const [isPromptModalOpen, setPromptModalOpen] = useState(false);
const [promptModalContent, setPromptModalContent] = useState({
Expand All @@ -133,6 +135,10 @@ function AnalyzeAreasContainer(props) {
(option) => option.title === selectedAnalysisLayer
)
);

if (selectedAnalysisLayer === HALF_EARTH_FUTURE_TILE_LAYER) {
setIsFirstLoad(false);
}
}, [selectedAnalysisLayer, precalculatedAOIOptions, setSelectedOption]);

const postDrawCallback = (geometry) => {
Expand Down Expand Up @@ -286,10 +292,22 @@ function AnalyzeAreasContainer(props) {
}
};

const handleOptionSelection = (option) => {
const handleOptionSelection = async (option) => {
if (option?.slug === HALF_EARTH_FUTURE_TILE_LAYER && isFirstLoad) {
setShowProgress(true);
}
handleLayerToggle(option?.slug);
changeUI({ selectedAnalysisLayer: option?.slug });
setTooltipIsVisible(false);

view.on('layerview-create', (event) => {
if (event.layer.id === HALF_EARTH_FUTURE_TILE_LAYER) {
if (isFirstLoad) {
setShowProgress(false);
setIsFirstLoad(false);
}
}
});
};

const handlePromptModalToggle = () => setPromptModalOpen(!isPromptModalOpen);
Expand All @@ -314,6 +332,7 @@ function AnalyzeAreasContainer(props) {
setSketchTooltipType={setSketchTooltipType}
setUpdatedGeometry={setUpdatedGeometry}
updatedGeometry={updatedGeometry}
showProgress={showProgress}
/>
);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -234,3 +234,38 @@
background-color: $white;
}
}

.radioContainer{
display: flex;
}

.progressBar {
position: relative;
width: 20px;
height: 20px;
}

.circle {
height: 100%;
right: 0px;
position: absolute;
border: solid 5px $alto;
border-top-color: $robins-egg-blue;
border-radius: 50%;
}

.border {
width: 100%;
transform: rotate(135deg);
animation: spin 1.3s steps(2) .2s infinite;
-webkit-animation: spin 1.3s linear infinite;
}

@keyframes spin {
0% {
transform: rotate(0deg);
}
100% {
transform: rotate(360deg);
}
}
1 change: 1 addition & 0 deletions src/containers/sidebars/map-layers/component.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ function MapLayers({
activeCategory={activeCategory}
handleGlobeUpdating={handleGlobeUpdating}
map={map}
view={view}
onboardingStep={onboardingStep}
onboardingType={onboardingType}
waitingInteraction={waitingInteraction}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ function ProtectedAreasSidebarCardComponent({
onboardingType,
waitingInteraction,
changeUI,
showProgress,
}) {
const t = useT();
const locale = useLocale();
Expand Down Expand Up @@ -146,6 +147,7 @@ function ProtectedAreasSidebarCardComponent({
type="checkbox"
variant="light"
key={layer.value}
showProgress={showProgress}
activeLayers={activeLayers}
onChange={handleLayerToggle}
themeCategorySlug={FUTURE_PLACES_SLUG}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import * as urlActions from 'actions/url-actions';

import { layerManagerToggle } from 'utils/layer-manager-utils';

import { HALF_EARTH_FUTURE_TILE_LAYER } from 'constants/layers-slugs';
import { LAYERS_CATEGORIES } from 'constants/mol-layers-configs';

import Component from './protected-areas-sidebar-card-component';
Expand All @@ -14,7 +15,10 @@ import mapStateToProps from './protected-areas-sidebar-card-selectors';
const actions = { ...metadataActions, ...urlActions };

function Container(props) {
const { activeLayers, changeGlobe } = props;
const { activeLayers, changeGlobe, view } = props;

const [showProgress, setShowProgress] = useState(false);
const [isFirstLoad, setIsFirstLoad] = useState(true);

const [selectedLayers, setSelectedLayers] = useState([]);

Expand All @@ -27,6 +31,19 @@ function Container(props) {
setSelectedLayers([...selectedLayers, option.value]);
}

if (option.value === HALF_EARTH_FUTURE_TILE_LAYER && isFirstLoad) {
setShowProgress(true);
}

view?.on('layerview-create', (event) => {
if (event.layer.id === HALF_EARTH_FUTURE_TILE_LAYER) {
if (isFirstLoad) {
setShowProgress(false);
setIsFirstLoad(false);
}
}
});

layerManagerToggle(
option.value,
activeLayers,
Expand All @@ -39,6 +56,7 @@ function Container(props) {
<Component
selectedLayers={selectedLayers}
handleLayerToggle={handleLayerToggle}
showProgress={showProgress}
{...props}
/>
);
Expand Down