-
Notifications
You must be signed in to change notification settings - Fork 9
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(basemap): Add and select basemap (#366)
- Loading branch information
1 parent
21ba66e
commit 5104f1f
Showing
45 changed files
with
1,341 additions
and
675 deletions.
There are no files selected for viewing
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file not shown.
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
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,89 @@ | ||
import { fireEvent } from "@testing-library/react"; | ||
import { renderWithTheme } from "../../utils/testing-utils/render-with-theme"; | ||
import { InputDropdown } from "./input-dropdown"; | ||
|
||
describe("Input Text", () => { | ||
it("Should render InputText without label", () => { | ||
const onChange = jest.fn(); | ||
|
||
const dom = renderWithTheme( | ||
<InputDropdown options={["test1", "test2"]} onChange={onChange} /> | ||
); | ||
expect(dom).toBeDefined(); | ||
if (!dom) { | ||
return; | ||
} | ||
const input: HTMLSelectElement | null = | ||
dom.container.querySelector("select"); | ||
const inputLabel: HTMLLabelElement | null = | ||
dom.container.querySelector("label"); | ||
|
||
expect(input).toBeInTheDocument(); | ||
expect(inputLabel).not.toBeInTheDocument(); | ||
}); | ||
|
||
it("Should render InputText with label", () => { | ||
const onChange = jest.fn(); | ||
|
||
const dom = renderWithTheme( | ||
<InputDropdown | ||
label="Label Text" | ||
options={["test1", "test2"]} | ||
onChange={onChange} | ||
/> | ||
); | ||
expect(dom).toBeDefined(); | ||
if (!dom) { | ||
return; | ||
} | ||
const input: HTMLSelectElement | null = | ||
dom.container.querySelector("select"); | ||
const inputLabel: HTMLLabelElement | null = | ||
dom.container.querySelector("label"); | ||
|
||
expect(input).toBeInTheDocument(); | ||
expect(input?.value).toBe("test1"); | ||
expect(inputLabel).toBeInTheDocument(); | ||
expect(inputLabel?.textContent).toEqual("Label Text"); | ||
}); | ||
|
||
it("Should change InputText", () => { | ||
let changedValue = ""; | ||
const onChange = jest | ||
.fn() | ||
.mockImplementation((event) => (changedValue = event.target.value)); | ||
|
||
const dom = renderWithTheme( | ||
<InputDropdown options={["test1", "test2"]} onChange={onChange} /> | ||
); | ||
expect(dom).toBeDefined(); | ||
if (!dom) { | ||
return; | ||
} | ||
const input: HTMLSelectElement | null = | ||
dom.container.querySelector("select"); | ||
if (input) { | ||
fireEvent.change(input, { target: { value: "test2" } }); | ||
} | ||
|
||
expect(changedValue).toBe("test2"); | ||
expect(onChange).toHaveBeenCalledTimes(1); | ||
}); | ||
|
||
it("Should handle value as prop", () => { | ||
const onChange = jest.fn(); | ||
|
||
const dom = renderWithTheme( | ||
<InputDropdown options={["test1", "test2"]} onChange={onChange} /> | ||
); | ||
expect(dom).toBeDefined(); | ||
if (!dom) { | ||
return; | ||
} | ||
const input: HTMLSelectElement | null = | ||
dom.container.querySelector("select"); | ||
|
||
expect(input?.value).toBe("test1"); | ||
expect(onChange).toHaveBeenCalledTimes(0); | ||
}); | ||
}); |
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,119 @@ | ||
import { type ChangeEvent, type FC, useId } from "react"; | ||
import styled, { useTheme } from "styled-components"; | ||
import { ExpandIcon } from "../expand-icon/expand-icon"; | ||
import { CollapseDirection, ExpandState } from "../../types"; | ||
|
||
const InputWrapper = styled.div` | ||
display: flex; | ||
flex-direction: column; | ||
align-items: flex-start; | ||
`; | ||
|
||
const SelectDiv = styled.div` | ||
position: relative; | ||
width: 100%; | ||
height: 46px; | ||
border-radius: 8px; | ||
background: ${({ theme }) => theme.colors.mainHiglightColor}; | ||
&:hover { | ||
background: ${({ theme }) => theme.colors.mainDimColor}; | ||
} | ||
magrin: 0; | ||
`; | ||
|
||
const Input = styled.select` | ||
width: 100%; | ||
padding: 13px 30px 13px 16px; | ||
border-radius: 8px; | ||
color: ${({ theme }) => theme.colors.secondaryFontColor}; | ||
border: 1px solid ${({ theme }) => theme.colors.mainHiglightColor}; | ||
&:hover { | ||
border: 1px solid ${({ theme }) => theme.colors.mainDimColor}; | ||
cursor: pointer; | ||
} | ||
&:focus { | ||
color: ${({ theme }) => theme.colors.fontColor}; | ||
outline: none; | ||
} | ||
appearance: none; | ||
background: transparent; | ||
magrin: 0; | ||
overflow: hidden; | ||
text-overflow: ellipsis; | ||
white-space: nowrap; | ||
`; | ||
|
||
const SelectOption = styled.option` | ||
height: 20px; | ||
background: ${({ theme }) => theme.colors.mainHiglightColor}; | ||
&:hover { | ||
background-color: ${({ theme }) => theme.colors.mainDimColor}; | ||
box-shadow: 0 0 10px 100px green inset; | ||
} | ||
&:checked { | ||
background-color: ${({ theme }) => theme.colors.mainDimColor}; | ||
box-shadow: 0 0 10px 100px green inset; | ||
} | ||
box-shadow: 0 0 10px 100px green inset; | ||
`; | ||
|
||
const ExpandIconWrapper = styled.div` | ||
position: absolute; | ||
top: 50%; | ||
transform: translate(0, -50%); | ||
right: 12px; | ||
`; | ||
|
||
const Label = styled.label` | ||
display: block; | ||
font-style: normal; | ||
font-weight: 500; | ||
font-size: 16px; | ||
line-height: 19px; | ||
margin-bottom: 8px; | ||
color: ${({ theme }) => theme.colors.fontColor}; | ||
`; | ||
|
||
interface InputDropdownProps { | ||
label?: string; | ||
options: string[]; | ||
onChange: (event: ChangeEvent<HTMLSelectElement>) => void; | ||
} | ||
|
||
export const InputDropdown: FC<InputDropdownProps> = ({ | ||
label, | ||
options, | ||
onChange, | ||
...rest | ||
}) => { | ||
const inputId = useId(); | ||
const theme = useTheme(); | ||
return ( | ||
<InputWrapper> | ||
{label && <Label htmlFor={inputId}>{label}</Label>} | ||
<SelectDiv> | ||
<ExpandIconWrapper> | ||
<ExpandIcon | ||
expandState={ExpandState.expanded} | ||
collapseDirection={CollapseDirection.bottom} | ||
fillExpanded={theme.colors.dropdownArrow} | ||
onClick={() => {}} | ||
/> | ||
</ExpandIconWrapper> | ||
<Input | ||
disabled={options.length <= 1} | ||
id={inputId} | ||
onChange={onChange} | ||
{...rest} | ||
> | ||
{options.map((item) => ( | ||
<SelectOption value={item} key={item}> | ||
{item} | ||
</SelectOption> | ||
))} | ||
</Input> | ||
</SelectDiv> | ||
</InputWrapper> | ||
); | ||
}; |
49 changes: 0 additions & 49 deletions
49
src/components/layers-panel/base-map-icon/base-map-icon.spec.tsx
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.