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

Add 'block' support to Select #11894

Merged
merged 3 commits into from Feb 14, 2020
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.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
9 changes: 7 additions & 2 deletions frontend/src/metabase/components/Select.jsx
Expand Up @@ -7,6 +7,8 @@ import PopoverWithTrigger from "metabase/components/PopoverWithTrigger";
import SelectButton from "./SelectButton";

import _ from "underscore";
import cx from "classnames";

import AccordionList from "./AccordionList";
import { createSelector } from "reselect";

Expand Down Expand Up @@ -174,7 +176,10 @@ export default class Select extends Component {
<PopoverWithTrigger
ref={ref => (this._popover = ref)}
triggerElement={
<SelectButton hasValue={selectedNames.length > 0}>
<SelectButton
className="full-width"
hasValue={selectedNames.length > 0}
>
{selectedNames.length > 0
? selectedNames.map((name, index) => (
<span key={index}>
Expand All @@ -185,7 +190,7 @@ export default class Select extends Component {
: placeholder}
</SelectButton>
}
triggerClasses={className}
triggerClasses={cx("flex", className)}
isInitiallyOpen={isInitiallyOpen}
verticalAttachments={["top", "bottom"]}
// keep the popover from jumping around one its been opened,
Expand Down
16 changes: 7 additions & 9 deletions frontend/src/metabase/components/SelectButton.jsx
Expand Up @@ -9,18 +9,16 @@ import cx from "classnames";
const SelectButton = ({ className, style, children, hasValue = true }) => (
<div
style={style}
className={cx(className, "AdminSelect", {
className={cx(className, "AdminSelect flex align-center", {
"text-medium": !hasValue,
})}
>
<span className="flex align-center">
<span className="AdminSelect-content mr1">{children}</span>
<Icon
className="AdminSelect-chevron flex-align-right"
name="chevrondown"
size={12}
/>
</span>
<span className="AdminSelect-content mr1">{children}</span>
<Icon
className="AdminSelect-chevron flex-align-right"
name="chevrondown"
size={12}
/>
</div>
);

Expand Down
Expand Up @@ -30,6 +30,7 @@ const ChartSettingFieldPicker = ({
return (
<div className={cx(className, "flex align-center")}>
<ChartSettingSelect
className="flex-full"
value={value}
options={options}
onChange={onChange}
Expand Down
Expand Up @@ -15,7 +15,7 @@ const ChartSettingSelect = ({
...props
}) => (
<Select
className={cx(className, "block flex-auto", {
className={cx(className, "block", {
disabled:
options.length === 0 ||
(options.length === 1 && options[0].value === value),
Expand Down
Expand Up @@ -969,38 +969,34 @@ exports[`Radio should render "vertical" correctly 1`] = `

exports[`Select should render "default" correctly 1`] = `
<a
className="no-decoration"
className="flex no-decoration"
id={undefined}
onClick={[Function]}
style={undefined}
>
<div
className="AdminSelect"
className="full-width AdminSelect flex align-center"
style={undefined}
>
<span
className="flex align-center"
className="AdminSelect-content mr1"
>
<span
className="AdminSelect-content mr1"
>
<span>
Entity Key

</span>
<span>
Entity Key

</span>
<svg
className="Icon Icon-chevrondown AdminSelect-chevron flex-align-right Icon-cxuQhR kTAgZA"
fill="currentcolor"
height={12}
viewBox="0 0 32 32"
width={12}
>
<path
d="M1 12 L16 26 L31 12 L27 8 L16 18 L5 8 z "
/>
</svg>
</span>
<svg
className="Icon Icon-chevrondown AdminSelect-chevron flex-align-right Icon-cxuQhR kTAgZA"
fill="currentcolor"
height={12}
viewBox="0 0 32 32"
width={12}
>
<path
d="M1 12 L16 26 L31 12 L27 8 L16 18 L5 8 z "
/>
</svg>
</div>
<span
className="hide"
Expand All @@ -1010,42 +1006,38 @@ exports[`Select should render "default" correctly 1`] = `

exports[`Select should render "kitchen_sink" correctly 1`] = `
<a
className="no-decoration"
className="flex no-decoration"
id={undefined}
onClick={[Function]}
style={undefined}
>
<div
className="AdminSelect"
className="full-width AdminSelect flex align-center"
style={undefined}
>
<span
className="flex align-center"
className="AdminSelect-content mr1"
>
<span
className="AdminSelect-content mr1"
>
<span>
Entity Key
,
</span>
<span>
Avatar Image URL

</span>
<span>
Entity Key
,
</span>
<span>
Avatar Image URL

</span>
<svg
className="Icon Icon-chevrondown AdminSelect-chevron flex-align-right Icon-cxuQhR kTAgZA"
fill="currentcolor"
height={12}
viewBox="0 0 32 32"
width={12}
>
<path
d="M1 12 L16 26 L31 12 L27 8 L16 18 L5 8 z "
/>
</svg>
</span>
<svg
className="Icon Icon-chevrondown AdminSelect-chevron flex-align-right Icon-cxuQhR kTAgZA"
fill="currentcolor"
height={12}
viewBox="0 0 32 32"
width={12}
>
<path
d="M1 12 L16 26 L31 12 L27 8 L16 18 L5 8 z "
/>
</svg>
</div>
<span
className="hide"
Expand All @@ -1055,42 +1047,38 @@ exports[`Select should render "kitchen_sink" correctly 1`] = `

exports[`Select should render "multiple" correctly 1`] = `
<a
className="no-decoration"
className="flex no-decoration"
id={undefined}
onClick={[Function]}
style={undefined}
>
<div
className="AdminSelect"
className="full-width AdminSelect flex align-center"
style={undefined}
>
<span
className="flex align-center"
className="AdminSelect-content mr1"
>
<span
className="AdminSelect-content mr1"
>
<span>
Entity Key
,
</span>
<span>
Avatar Image URL

</span>
<span>
Entity Key
,
</span>
<span>
Avatar Image URL

</span>
<svg
className="Icon Icon-chevrondown AdminSelect-chevron flex-align-right Icon-cxuQhR kTAgZA"
fill="currentcolor"
height={12}
viewBox="0 0 32 32"
width={12}
>
<path
d="M1 12 L16 26 L31 12 L27 8 L16 18 L5 8 z "
/>
</svg>
</span>
<svg
className="Icon Icon-chevrondown AdminSelect-chevron flex-align-right Icon-cxuQhR kTAgZA"
fill="currentcolor"
height={12}
viewBox="0 0 32 32"
width={12}
>
<path
d="M1 12 L16 26 L31 12 L27 8 L16 18 L5 8 z "
/>
</svg>
</div>
<span
className="hide"
Expand All @@ -1100,38 +1088,34 @@ exports[`Select should render "multiple" correctly 1`] = `

exports[`Select should render "search" correctly 1`] = `
<a
className="no-decoration"
className="flex no-decoration"
id={undefined}
onClick={[Function]}
style={undefined}
>
<div
className="AdminSelect"
className="full-width AdminSelect flex align-center"
style={undefined}
>
<span
className="flex align-center"
className="AdminSelect-content mr1"
>
<span
className="AdminSelect-content mr1"
>
<span>
Entity Key

</span>
<span>
Entity Key

</span>
<svg
className="Icon Icon-chevrondown AdminSelect-chevron flex-align-right Icon-cxuQhR kTAgZA"
fill="currentcolor"
height={12}
viewBox="0 0 32 32"
width={12}
>
<path
d="M1 12 L16 26 L31 12 L27 8 L16 18 L5 8 z "
/>
</svg>
</span>
<svg
className="Icon Icon-chevrondown AdminSelect-chevron flex-align-right Icon-cxuQhR kTAgZA"
fill="currentcolor"
height={12}
viewBox="0 0 32 32"
width={12}
>
<path
d="M1 12 L16 26 L31 12 L27 8 L16 18 L5 8 z "
/>
</svg>
</div>
<span
className="hide"
Expand All @@ -1141,38 +1125,34 @@ exports[`Select should render "search" correctly 1`] = `

exports[`Select should render "sections" correctly 1`] = `
<a
className="no-decoration"
className="flex no-decoration"
id={undefined}
onClick={[Function]}
style={undefined}
>
<div
className="AdminSelect"
className="full-width AdminSelect flex align-center"
style={undefined}
>
<span
className="flex align-center"
className="AdminSelect-content mr1"
>
<span
className="AdminSelect-content mr1"
>
<span>
Entity Key

</span>
<span>
Entity Key

</span>
<svg
className="Icon Icon-chevrondown AdminSelect-chevron flex-align-right Icon-cxuQhR kTAgZA"
fill="currentcolor"
height={12}
viewBox="0 0 32 32"
width={12}
>
<path
d="M1 12 L16 26 L31 12 L27 8 L16 18 L5 8 z "
/>
</svg>
</span>
<svg
className="Icon Icon-chevrondown AdminSelect-chevron flex-align-right Icon-cxuQhR kTAgZA"
fill="currentcolor"
height={12}
viewBox="0 0 32 32"
width={12}
>
<path
d="M1 12 L16 26 L31 12 L27 8 L16 18 L5 8 z "
/>
</svg>
</div>
<span
className="hide"
Expand Down