-
Notifications
You must be signed in to change notification settings - Fork 4.6k
🪟 [Multi Cloud] Geography Dropdown Component #18543
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
Closed
Closed
Changes from 20 commits
Commits
Show all changes
22 commits
Select commit
Hold shift + click to select a range
a9d30d8
Adds geography dropdown.
7100584
Barebone styling.
1c92b2b
On hover styles.
35d4c74
Last option styling.
18623f0
Tweaks.
0e5561a
Cleanup.
c686476
Adds flag npm package to package.json.
323667c
Corrects storybook build error.
f201347
Style corrections and label change.
964bb1f
Storybook displays options in primary component version.
c12dc9e
Different flag library as per request.
e3f74dd
Flag styling.
5a248fc
option selection and styles work.
4086b24
HOver styles work.
762f56d
Tweaks.
713c362
Corrects storybook component versions.
8e95cdd
Requested changes. Focus/hover styles still need work.
ff68742
Corrects focus and hover styles.
4f9c3bf
Requested changes. Correcting wrong merge commit.
cdbd435
Stylelint regex pattern correction.
5322958
Requested changes.
dad6417
Correcting stylelint. Regex escape not needed.
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
This file contains hidden or 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
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains hidden or 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
70 changes: 70 additions & 0 deletions
70
airbyte-webapp/src/components/GeographyDropdown/GeographyDropdown.module.scss
This file contains hidden or 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,70 @@ | ||
@use "scss/variables"; | ||
@use "scss/colors"; | ||
|
||
.menuList { | ||
padding: 10px 16px; | ||
margin-top: 10px; | ||
max-width: 300px; | ||
color: colors.$blue-300; | ||
border-top: solid colors.$dark-blue-50 1px; | ||
|
||
:first-child { | ||
padding-right: 8px; | ||
} | ||
|
||
:last-child { | ||
font-size: variables.$spacing-lg; | ||
} | ||
} | ||
|
||
.reactSelectContainer { | ||
width: 300px; | ||
|
||
& .option { | ||
display: flex; | ||
align-items: center; | ||
padding: 6px 20px 6px 6px; | ||
margin: 0 10px; | ||
max-width: 280px; | ||
font-weight: 500; | ||
color: colors.$black; | ||
border-radius: 10px; | ||
cursor: pointer; | ||
} | ||
} | ||
|
||
.flag { | ||
padding: 9px 6px; | ||
border-radius: 7px; | ||
background-color: colors.$white; | ||
display: flex; | ||
align-items: center; | ||
} | ||
|
||
.label { | ||
padding-left: 8px; | ||
} | ||
|
||
.optionLabel { | ||
display: flex; | ||
align-items: center; | ||
font-weight: 500; | ||
} | ||
|
||
/* stylelint-disable no-descending-specificity */ | ||
:global(.reactSelect__option--is-focused).option { | ||
background-color: colors.$grey-50; | ||
|
||
&:active { | ||
background-color: colors.$grey-50; | ||
} | ||
} | ||
|
||
:global(.reactSelect__option--is-selected).option { | ||
background-color: colors.$blue-50; | ||
|
||
&:active { | ||
background-color: colors.$blue-50; | ||
} | ||
} | ||
natalyjazzviolin marked this conversation as resolved.
Show resolved
Hide resolved
|
||
/* stylelint-enable no-descending-specificity */ |
85 changes: 85 additions & 0 deletions
85
airbyte-webapp/src/components/GeographyDropdown/GeographyDropdown.tsx
This file contains hidden or 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,85 @@ | ||
import { faPlus } from "@fortawesome/free-solid-svg-icons"; | ||
import { FontAwesomeIcon } from "@fortawesome/react-fontawesome"; | ||
import React, { useState } from "react"; | ||
import { useIntl } from "react-intl"; | ||
import { components, OptionProps, MenuListProps, StylesConfig } from "react-select"; | ||
|
||
import "/node_modules/flag-icons/css/flag-icons.min.css"; | ||
|
||
import { DropDown } from "components/ui/DropDown"; | ||
import { DropdownProps } from "components/ui/DropDown"; | ||
|
||
import { Geography } from "core/request/AirbyteClient"; | ||
|
||
import styles from "./GeographyDropdown.module.scss"; | ||
|
||
const GeographyOption: React.FC<OptionProps> = (props) => { | ||
const { formatMessage } = useIntl(); | ||
return ( | ||
<components.Option className={styles.option} {...props}> | ||
<div className={styles.flag}> | ||
<span className={`fi fi-${props.label === "auto" ? "us" : props.label}`} /> | ||
</div> | ||
<span className={styles.label}>{formatMessage({ id: `geography.${props.label}` })}</span> | ||
natalyjazzviolin marked this conversation as resolved.
Show resolved
Hide resolved
|
||
</components.Option> | ||
); | ||
}; | ||
|
||
const MenuList = (props: MenuListProps) => { | ||
const { formatMessage } = useIntl(); | ||
return ( | ||
<components.MenuList {...props}> | ||
{props.children} | ||
<div className={styles.menuList}> | ||
<FontAwesomeIcon icon={faPlus} /> | ||
<span>{formatMessage({ id: "geography.new" })}</span> | ||
</div> | ||
</components.MenuList> | ||
); | ||
}; | ||
|
||
interface GeographySelectOption { | ||
label: Geography; | ||
value: Geography; | ||
} | ||
|
||
export const GeographyDropdown: React.FC<DropdownProps<GeographySelectOption>> = ({ options }) => { | ||
const [option, setOption] = useState({}); | ||
const { formatMessage } = useIntl(); | ||
const handleOptionSelect = (event: { label: string }) => { | ||
setOption(event.label); | ||
}; | ||
|
||
const formatOptionLabel = ({ label }: { label: string }) => { | ||
return ( | ||
<div className={styles.optionLabel}> | ||
<div className={styles.flag}> | ||
<span className={`fi fi-${label === "auto" ? "us" : label}`} /> | ||
</div> | ||
<span className={styles.label}> | ||
{formatMessage({ id: `geography.${label}`, defaultMessage: label.toUpperCase() })} | ||
</span> | ||
</div> | ||
); | ||
}; | ||
|
||
const customStyles: StylesConfig<GeographySelectOption> = { | ||
valueContainer: () => ({ | ||
display: "flex", | ||
}), | ||
}; | ||
|
||
return ( | ||
<DropDown | ||
className={styles.reactSelectContainer} | ||
classNamePrefix="reactSelect" | ||
options={options} | ||
components={{ Option: GeographyOption, MenuList }} | ||
onChange={handleOptionSelect} | ||
value={option} | ||
formatOptionLabel={formatOptionLabel} | ||
styles={customStyles} | ||
placeholder={formatMessage({ id: "geography.select" })} | ||
/> | ||
); | ||
}; |
31 changes: 31 additions & 0 deletions
31
airbyte-webapp/src/components/GeographyDropdown/index.stories.tsx
This file contains hidden or 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,31 @@ | ||
import { ComponentStory, ComponentMeta } from "@storybook/react"; | ||
|
||
import { GeographyDropdown } from "./GeographyDropdown"; | ||
|
||
export default { | ||
title: "Common/GeographyDropdown", | ||
component: GeographyDropdown, | ||
} as ComponentMeta<typeof GeographyDropdown>; | ||
|
||
const Template: ComponentStory<typeof GeographyDropdown> = (args) => <GeographyDropdown {...args} />; | ||
|
||
export const Empty = Template.bind({}); | ||
Empty.args = {}; | ||
|
||
export const Primary = Template.bind({}); | ||
Primary.args = { | ||
options: [ | ||
{ | ||
value: "us", | ||
label: "us", | ||
}, | ||
{ | ||
value: "auto", | ||
label: "auto", | ||
}, | ||
{ | ||
value: "eu", | ||
label: "eu", | ||
}, | ||
], | ||
}; |
This file contains hidden or 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 @@ | ||
export { GeographyDropdown } from "./GeographyDropdown"; |
This file contains hidden or 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
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.
Uh oh!
There was an error while loading. Please reload this page.