Skip to content

Commit

Permalink
dropdown button update (#31)
Browse files Browse the repository at this point in the history
  • Loading branch information
ivaylo-matov authored Sep 13, 2024
1 parent ca953bf commit 2aac9ed
Show file tree
Hide file tree
Showing 7 changed files with 49 additions and 15 deletions.
4 changes: 2 additions & 2 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@dynamods/dynamo-home",
"version": "1.0.18",
"version": "1.0.19",
"description": "Dynamo Home",
"author": "Autodesk Inc.",
"main": "index.tsx",
Expand Down
2 changes: 1 addition & 1 deletion src/components/Samples/PageSamples.module.css
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
.wideDropdown {
width: 200px;
width: 185px;
}
7 changes: 5 additions & 2 deletions src/components/Samples/PageSamples.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import { CustomSampleFirstCellRenderer } from "./CustomSampleFirstCellRenderer";
import { SamplesGrid } from './SamplesGrid';
import { openFile, showSamplesCommand, saveHomePageSettings } from '../../functions/utility';
import { useSettings } from '../SettingsContext';
import { CustomDropdown } from "../Sidebar/CustomDropDown";
import { CustomDropdown } from '../Sidebar/CustomDropDown';
import styles from './PageSamples.module.css';

export const SamplesPage = ({ samplesViewMode }) => {
Expand Down Expand Up @@ -133,10 +133,13 @@ export const SamplesPage = ({ samplesViewMode }) => {
placeholder={<FormattedMessage id="samples.showsamples.text" />}
onSelectionChange={handleShowSamplesClick}
options={[
{ label: <FormattedMessage id="samples.showsamples.files.text" />, value: 'open-files' },
{ label: <FormattedMessage id="samples.showsamples.files.text" />, value: 'open-graphs' },
{ label: <FormattedMessage id="samples.showsamples.datasets.text" />, value: 'open-datasets' }
]}
className={styles.wideDropdown}
showDivider={false}
wholeButtonActionable={true}
disableArrowHoverShadow={true}
/>
</div>
</div>
Expand Down
4 changes: 4 additions & 0 deletions src/components/Sidebar/CustomDropDown.module.css
Original file line number Diff line number Diff line change
Expand Up @@ -113,4 +113,8 @@
height: 100%;
background-color: #9B9B9B;
margin: 0px;
}

.no-hover-shadow .arrow-container:hover {
box-shadow: none !important;
}
43 changes: 35 additions & 8 deletions src/components/Sidebar/CustomDropDown.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,21 @@ import { useState, useRef, useEffect } from 'react';
import styles from './CustomDropDown.module.css';
import { OpenArrow } from '../Common/Arrow';

export const CustomDropdown = ({ id, options, placeholder, onSelectionChange, className }: Dropdown & { className?: string }) => {
export const CustomDropdown = ({
id,
options,
placeholder,
onSelectionChange,
className,
showDivider = true,
wholeButtonActionable = false,
disableArrowHoverShadow = false
}: Dropdown & {
className?: string,
showDivider?: boolean,
wholeButtonActionable?: boolean,
disableArrowHoverShadow?: boolean
}) => {
const [isOpen, setIsOpen] = useState(false);
const [lastSelected, setLastSelected] = useState(options[0]);
const dropdownRef = useRef(null);
Expand Down Expand Up @@ -43,14 +57,27 @@ export const CustomDropdown = ({ id, options, placeholder, onSelectionChange, cl
}, [isOpen]);

return (
<div className={`${styles['custom-dropdown']} ${isOpen ? styles.open : ''} ${className}`} ref={dropdownRef}>
<div className={styles['dropdown-selected']} onClick={handleDefaultAction}>
<div
className={`
${styles['custom-dropdown']}
${isOpen ? styles.open : ''}
${disableArrowHoverShadow ? styles['no-hover-shadow'] : ''}
${className}
`}
ref={dropdownRef}>
<div
className={styles['dropdown-selected']}
onClick={wholeButtonActionable ? toggleDropdown : undefined}
>
<span>{placeholder}</span>
<span className={styles['vertical-line']}></span>
<div className={styles['arrow-container']} onClick={(e) => {
e.stopPropagation();
toggleDropdown();
}}>
{showDivider && <span className={styles['vertical-line']}></span>}
<div
className={styles['arrow-container']}
onClick={wholeButtonActionable ? undefined : (e) => {
e.stopPropagation();
toggleDropdown();
}}
>
<OpenArrow isOpen={isOpen} color={arrowColor} />
</div>
</div>
Expand Down
2 changes: 1 addition & 1 deletion src/functions/utility.ts
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ export function showSamplesCommand(value: ShowSamplesCommand) {
if (value === 'open-graphs' && window.chrome?.webview !== undefined) {
window.chrome.webview.hostObjects.scriptObject.ShowSampleFilesInFolder();
}
if (value == 'open-datasets' && window.chrome?.webview !== undefined) {
if (value === 'open-datasets' && window.chrome?.webview !== undefined) {
window.chrome.webview.hostObjects.scriptObject.ShowSampleDatasetsInFolder();
}
}
Expand Down

0 comments on commit 2aac9ed

Please sign in to comment.