Skip to content

Saleor Core: the high performance, composable, headless commerce API.

Fix styles for single autocomplete select

dominik-zeglen33114f011113
diff --git a/saleor/static/dashboard-next/components/SingleAutocompleteSelectField/SingleAutocompleteSelectField.tsx b/saleor/static/dashboard-next/components/SingleAutocompleteSelectField/SingleAutocompleteSelectField.tsx
index 152ccc256b..6082f967a2 100644
--- a/saleor/static/dashboard-next/components/SingleAutocompleteSelectField/SingleAutocompleteSelectField.tsx
+++ b/saleor/static/dashboard-next/components/SingleAutocompleteSelectField/SingleAutocompleteSelectField.tsx
@@ -24,15 +24,17 @@ const styles = (theme: Theme) =>
position: "relative"
},
paper: {
+ borderRadius: 4,
left: 0,
marginTop: theme.spacing.unit,
+ padding: 8,
position: "absolute",
right: 0,
zIndex: 1
}
});
-interface SingleAutocompleteSelectFieldProps extends WithStyles<typeof styles> {
+export interface SingleAutocompleteSelectFieldProps {
error?: boolean;
name: string;
choices: Array<{
@@ -83,7 +85,7 @@ const SingleAutocompleteSelectFieldComponent = withStyles(styles, {
InputProps,
fetchChoices,
onChange
- }: SingleAutocompleteSelectFieldProps) => {
+ }: SingleAutocompleteSelectFieldProps & WithStyles<typeof styles>) => {
const handleChange = item => onChange({ target: { name, value: item } });
return (
diff --git a/saleor/static/dashboard-next/storybook/stories/components/SingleAutocompleteSelectField.tsx b/saleor/static/dashboard-next/storybook/stories/components/SingleAutocompleteSelectField.tsx
index 03879b6e83..4f019a6142 100644
--- a/saleor/static/dashboard-next/storybook/stories/components/SingleAutocompleteSelectField.tsx
+++ b/saleor/static/dashboard-next/storybook/stories/components/SingleAutocompleteSelectField.tsx
@@ -3,6 +3,7 @@ import * as React from "react";
import Form from "../../../components/Form";
import SingleAutocompleteSelectField from "../../../components/SingleAutocompleteSelectField";
+import CardDecorator from "../../CardDecorator";
import Decorator from "../../Decorator";
import { ChoiceProvider } from "../../mock";
@@ -21,7 +22,15 @@ const suggestions = [
"Zimbabwe"
].map(c => ({ label: c, value: c.toLocaleLowerCase().replace(/\s+/, "_") }));
+const props = {
+ label: "Country",
+ loading: false,
+ name: "country",
+ placeholder: "Select country"
+};
+
storiesOf("Generics / SingleAutocompleteSelectField", module)
+ .addDecorator(CardDecorator)
.addDecorator(Decorator)
.add("with loading data", () => (
<Form initial={{ country: suggestions[0] }}>
@@ -29,13 +38,12 @@ storiesOf("Generics / SingleAutocompleteSelectField", module)
<ChoiceProvider choices={suggestions}>
{({ choices, fetchChoices }) => (
<SingleAutocompleteSelectField
+ {...props}
choices={choices}
fetchChoices={fetchChoices}
helperText={`Value: ${data.country.value}`}
loading={true}
- name="country"
onChange={change}
- placeholder="Select country"
value={data.country}
/>
)}
@@ -49,13 +57,11 @@ storiesOf("Generics / SingleAutocompleteSelectField", module)
<ChoiceProvider choices={suggestions}>
{({ choices, fetchChoices }) => (
<SingleAutocompleteSelectField
+ {...props}
choices={choices}
fetchChoices={fetchChoices}
helperText={`Value: ${data.country.value}`}
- loading={false}
- name="country"
onChange={change}
- placeholder="Select country"
value={data.country}
/>
)}
@@ -69,15 +75,14 @@ storiesOf("Generics / SingleAutocompleteSelectField", module)
<ChoiceProvider choices={suggestions}>
{({ choices, fetchChoices, loading }) => (
<SingleAutocompleteSelectField
+ {...props}
choices={choices}
- custom={true}
fetchChoices={fetchChoices}
helperText={`Value: ${data.country.value}`}
loading={loading}
- name="country"
onChange={change}
- placeholder="Select country"
value={data.country}
+ custom={true}
/>
)}
</ChoiceProvider>
diff --git a/saleor/static/dashboard-next/theme.ts b/saleor/static/dashboard-next/theme.ts
index 03719d4801..3826ae4471 100644
--- a/saleor/static/dashboard-next/theme.ts
+++ b/saleor/static/dashboard-next/theme.ts
@@ -151,6 +151,14 @@ export default (colors: IThemeColors): Theme =>
"&:focus": {
backgroundColor: colors.input.default
}
+ },
+ root: {
+ "&$selected": {
+ "&:hover": {
+ backgroundColor: colors.input.default
+ },
+ backgroundColor: colors.input.default
+ }
}
},
MuiMenu: {
@@ -255,6 +263,9 @@ export default (colors: IThemeColors): Theme =>
}
},
MuiTouchRipple: {
+ child: {
+ backgroundColor: fade(colors.primary, 0.2)
+ },
childLeaving: {
backgroundColor: fade(colors.primary, 0.2)
},