-
Notifications
You must be signed in to change notification settings - Fork 0
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
Modernize layer selector #259
Draft
steveoh
wants to merge
7
commits into
main
Choose a base branch
from
feat/layer-selector-tw
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Draft
Changes from all commits
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
b31e505
chore(popover): prettier
steveoh 0da5794
wip(layer-selector): create RAC layer selector
steveoh 2fee6ec
test(layer-selector): update args
steveoh 0f0d236
deps(monorepo): update packages
steveoh 0d46774
refactor(layer-selector): replace svg with icon
steveoh b50e7ef
chore(layer-selector): add types
steveoh 04bea76
chore(layer-selector): sort styles
steveoh File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
import { LayerSelector } from './LayerSelector.tsx'; | ||
|
||
export default { | ||
component: LayerSelector, | ||
parameters: { | ||
layout: 'padded', | ||
}, | ||
args: { | ||
expanded: false, | ||
options: { | ||
baseLayers: [ | ||
{ id: 'Hybrid', name: 'Hybrid' }, | ||
{ id: 'Lite', name: 'Lite' }, | ||
{ id: 'Terrain', name: 'Terrain' }, | ||
{ id: 'Topo', name: 'Topo' }, | ||
{ id: 'Color IR', name: 'Color IR' }, | ||
], | ||
overlays: [ | ||
{ id: 'Address points', name: 'Address points' }, | ||
{ id: 'Land ownership', name: 'Land ownership' }, | ||
], | ||
}, | ||
}, | ||
}; | ||
|
||
export const Example = (args) => <LayerSelector {...args}></LayerSelector>; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,97 @@ | ||
import { | ||
Collection, | ||
Dialog, | ||
DialogTrigger, | ||
Popover as RACPopover, | ||
Header, | ||
} from 'react-aria-components'; | ||
import { LayersIcon } from 'lucide-react'; | ||
import type { PopoverProps } from 'react-aria-components'; | ||
import { | ||
Button, | ||
Radio, | ||
RadioGroup, | ||
CheckboxGroup, | ||
Checkbox, | ||
} from '@ugrc/utah-design-system/src'; | ||
import MapView from '@arcgis/core/views/MapView'; | ||
|
||
type LayerFactory = { | ||
Factory: new () => __esri.Layer; | ||
url: string; | ||
id: string; | ||
opacity: number; | ||
}; | ||
type SelectorOptions = { | ||
view: MapView; | ||
quadWord: string; | ||
baseLayers: Array< | ||
string | { token: string; selected: boolean } | LayerFactory | ||
>; | ||
overlays?: Array<string | LayerFactory>; | ||
position: 'top-left' | 'top-right' | 'bottom-left' | 'bottom-right'; | ||
}; | ||
|
||
const Popover = (props: PopoverProps) => { | ||
return ( | ||
<RACPopover | ||
{...props} | ||
className={({ isEntering, isExiting }) => | ||
`group min-w-48 max-w-sm overflow-y-auto rounded-lg bg-white px-3 py-2 ring-1 ring-black/10 drop-shadow-lg dark:bg-zinc-800 dark:ring-white/10 ${ | ||
isEntering | ||
? 'animate-in fade-in placement-top:slide-in-from-bottom-1 placement-bottom:slide-in-from-top-1 duration-500 ease-out' | ||
: '' | ||
} ${ | ||
isExiting | ||
? 'animate-out fade-out placement-top:slide-out-to-bottom-1 placement-bottom:slide-out-to-top-1 duration-150 ease-in' | ||
: '' | ||
} ` | ||
} | ||
/> | ||
); | ||
}; | ||
|
||
export function LayerSelector({ | ||
options, | ||
...props | ||
}: { | ||
options: SelectorOptions; | ||
}) { | ||
return ( | ||
<DialogTrigger {...props}> | ||
<div className="inline-flex max-w-fit border border-black bg-white dark:border-zinc-500 dark:bg-zinc-900"> | ||
<Button | ||
aria-label="Map layers" | ||
className="px-1.5 outline-none focus-visible:ring-2 focus-visible:ring-white/75" | ||
variant="icon" | ||
> | ||
<LayersIcon className="block size-8 p-1" /> | ||
</Button> | ||
</div> | ||
<Popover> | ||
<Dialog className="outline-none"> | ||
<Header className="font-bold dark:text-white">Base maps</Header> | ||
<RadioGroup className="flex-1"> | ||
<Collection items={options.baseLayers}> | ||
{(item) => ( | ||
<Radio className="pl-2" value={item.name}> | ||
{item.name} | ||
</Radio> | ||
)} | ||
</Collection> | ||
</RadioGroup> | ||
<Header className="pt-3 font-bold dark:text-white">Overlays</Header> | ||
<CheckboxGroup className="flex-1"> | ||
<Collection items={props.options.overlays}> | ||
{(item) => ( | ||
<Checkbox className="pl-2" value="test"> | ||
{item.name} | ||
</Checkbox> | ||
)} | ||
</Collection> | ||
</CheckboxGroup> | ||
</Dialog> | ||
</Popover> | ||
</DialogTrigger> | ||
); | ||
} |
19 changes: 8 additions & 11 deletions
19
packages/layer-selector/src/LayerSelectorContainer.stories.jsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,9 +1,10 @@ | ||
import ugrcTheme from './packages/tailwind-preset/src/index'; | ||
import rac from 'tailwindcss-react-aria-components'; | ||
import animate from 'tailwindcss-animate'; | ||
|
||
export default { | ||
content: ['./packages/**/*.{js,jsx,ts,tsx}'], | ||
darkMode: ['class'], | ||
presets: [ugrcTheme], | ||
plugins: [rac], | ||
plugins: [rac, animate], | ||
}; |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could this be added to the preset? If not, then it needs to be documented.