Fix/411 asset dropdown style (#535)

* fix: arrow missing from select box

* fix: select box styles on firefox
This commit is contained in:
Matthew Russell 2022-06-10 16:12:51 -07:00 committed by GitHub
parent 9941c9bfaa
commit ff8990c257
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
10 changed files with 39 additions and 47 deletions

View File

@ -6,6 +6,7 @@ const vegaCustomClasses = require('../../libs/tailwindcss-config/src/vega-custom
module.exports = { module.exports = {
content: [ content: [
join(__dirname, 'src/**/*.{js,ts,jsx,tsx}'), join(__dirname, 'src/**/*.{js,ts,jsx,tsx}'),
'libs/ui-toolkit/src/utils/shared.ts',
...createGlobPatternsForDependencies(__dirname), ...createGlobPatternsForDependencies(__dirname),
], ],
darkMode: 'class', darkMode: 'class',

View File

@ -6,6 +6,7 @@ const vegaCustomClasses = require('../../libs/tailwindcss-config/src/vega-custom
module.exports = { module.exports = {
content: [ content: [
join(__dirname, 'src/**/*.{js,ts,jsx,tsx}'), join(__dirname, 'src/**/*.{js,ts,jsx,tsx}'),
'libs/ui-toolkit/src/utils/shared.ts',
...createGlobPatternsForDependencies(__dirname), ...createGlobPatternsForDependencies(__dirname),
], ],
darkMode: 'class', darkMode: 'class',

View File

@ -6,6 +6,7 @@ const vegaCustomClasses = require('../../libs/tailwindcss-config/src/vega-custom
module.exports = { module.exports = {
content: [ content: [
join(__dirname, 'src/**/*.{js,ts,jsx,tsx}'), join(__dirname, 'src/**/*.{js,ts,jsx,tsx}'),
'libs/ui-toolkit/src/utils/shared.ts',
...createGlobPatternsForDependencies(__dirname), ...createGlobPatternsForDependencies(__dirname),
], ],
darkMode: 'class', darkMode: 'class',

View File

@ -6,6 +6,7 @@ const vegaCustomClasses = require('../../libs/tailwindcss-config/src/vega-custom
module.exports = { module.exports = {
content: [ content: [
join(__dirname, 'src/**/*.{js,ts,jsx,tsx}'), join(__dirname, 'src/**/*.{js,ts,jsx,tsx}'),
'libs/ui-toolkit/src/utils/shared.ts',
...createGlobPatternsForDependencies(__dirname), ...createGlobPatternsForDependencies(__dirname),
], ],
darkMode: 'class', darkMode: 'class',

View File

@ -7,6 +7,7 @@ module.exports = {
content: [ content: [
join(__dirname, 'pages/**/*.{js,ts,jsx,tsx}'), join(__dirname, 'pages/**/*.{js,ts,jsx,tsx}'),
join(__dirname, 'components/**/*.{js,ts,jsx,tsx}'), join(__dirname, 'components/**/*.{js,ts,jsx,tsx}'),
'libs/ui-toolkit/src/utils/shared.ts',
...createGlobPatternsForDependencies(__dirname), ...createGlobPatternsForDependencies(__dirname),
], ],
darkMode: 'class', darkMode: 'class',

View File

@ -3,10 +3,7 @@ import { forwardRef } from 'react';
import classNames from 'classnames'; import classNames from 'classnames';
import type { IconName } from '../icon'; import type { IconName } from '../icon';
import { Icon } from '../icon'; import { Icon } from '../icon';
import { import { defaultFormElement } from '../../utils/shared';
includesLeftPadding,
includesRightPadding,
} from '../../utils/class-names';
type InputRootProps = InputHTMLAttributes<HTMLInputElement> & { type InputRootProps = InputHTMLAttributes<HTMLInputElement> & {
hasError?: boolean; hasError?: boolean;
@ -60,37 +57,6 @@ type AffixProps = InputPrepend | InputAppend;
type InputProps = InputRootProps & AffixProps; type InputProps = InputRootProps & AffixProps;
export const inputClassNames = ({
hasError,
className,
}: {
hasError?: boolean;
className?: string;
}) => {
return classNames(
[
'appearance-none',
'flex items-center w-full',
'box-border',
'border rounded-none',
'bg-clip-padding',
'border-black-60 dark:border-white-60',
'bg-black-25 dark:bg-white-25',
'text-black placeholder:text-black-60 dark:text-white dark:placeholder:text-white-60',
'text-ui',
'focus-visible:shadow-focus dark:focus-visible:shadow-focus-dark',
'focus-visible:outline-0',
'disabled:bg-black-10 disabled:dark:bg-white-10',
],
{
'pl-8': !includesLeftPadding(className),
'pr-8': !includesRightPadding(className),
'border-vega-pink dark:border-vega-pink': hasError,
},
className
);
};
export const inputStyle = ({ export const inputStyle = ({
style, style,
disabled, disabled,
@ -165,17 +131,17 @@ export const Input = forwardRef<HTMLInputElement, InputProps>(
const hasPrepended = !!(prependIconName || prependElement); const hasPrepended = !!(prependIconName || prependElement);
const hasAppended = !!(appendIconName || appendElement); const hasAppended = !!(appendIconName || appendElement);
const inputClassName = classNames('h-28', className, { const inputClassName = classNames('appearance-none', 'h-28', className, {
'pl-28': hasPrepended ?? hasAppended, 'pl-28': hasPrepended,
'pr-28': hasAppended,
'border-vega-pink dark:border-vega-pink': hasError,
}); });
const input = ( const input = (
<input <input
{...props} {...props}
ref={ref} ref={ref}
className={classNames( className={classNames(defaultFormElement, inputClassName)}
inputClassNames({ className: inputClassName, hasError })
)}
/> />
); );

View File

@ -1,7 +1,7 @@
import type { SelectHTMLAttributes } from 'react'; import type { SelectHTMLAttributes } from 'react';
import { forwardRef } from 'react'; import { forwardRef } from 'react';
import classNames from 'classnames'; import classNames from 'classnames';
import { inputClassNames } from '../input'; import { defaultFormElement } from '../../utils/shared';
export interface SelectProps extends SelectHTMLAttributes<HTMLSelectElement> { export interface SelectProps extends SelectHTMLAttributes<HTMLSelectElement> {
hasError?: boolean; hasError?: boolean;
@ -11,11 +11,13 @@ export interface SelectProps extends SelectHTMLAttributes<HTMLSelectElement> {
} }
export const Select = forwardRef<HTMLSelectElement, SelectProps>( export const Select = forwardRef<HTMLSelectElement, SelectProps>(
(props, ref) => ( ({ className, hasError, ...props }, ref) => (
<select <select
ref={ref} ref={ref}
{...props} {...props}
className={classNames(inputClassNames(props), 'h-28')} className={classNames(defaultFormElement, className, 'h-28', {
'border-vega-pink dark:border-vega-pink': hasError,
})}
/> />
) )
); );

View File

@ -1,6 +1,7 @@
import classNames from 'classnames';
import type { TextareaHTMLAttributes } from 'react'; import type { TextareaHTMLAttributes } from 'react';
import { forwardRef } from 'react'; import { forwardRef } from 'react';
import { inputClassNames } from '../input'; import { defaultFormElement } from '../../utils/shared';
export interface TextAreaProps export interface TextAreaProps
extends TextareaHTMLAttributes<HTMLTextAreaElement> { extends TextareaHTMLAttributes<HTMLTextAreaElement> {
@ -9,7 +10,10 @@ export interface TextAreaProps
} }
export const TextArea = forwardRef<HTMLTextAreaElement, TextAreaProps>( export const TextArea = forwardRef<HTMLTextAreaElement, TextAreaProps>(
(props, ref) => ( ({ className, hasError, ...props }, ref) => {
<textarea {...props} ref={ref} className={inputClassNames(props)} /> const classes = classNames(defaultFormElement, className, {
) 'border-vega-pink dark:border-vega-pink': hasError,
});
return <textarea {...props} ref={ref} className={classes} />;
}
); );

View File

@ -0,0 +1,14 @@
export const defaultFormElement = [
'flex items-center w-full',
'box-border',
'border rounded-none',
'bg-clip-padding',
'border-black-60 dark:border-white-60',
'bg-black-25 dark:bg-white-25',
'text-black placeholder:text-black-60 dark:text-white dark:placeholder:text-white-60',
'text-ui',
'px-8',
'focus-visible:shadow-focus dark:focus-visible:shadow-focus-dark',
'focus-visible:outline-0',
'disabled:bg-black-10 disabled:dark:bg-white-10',
];

View File

@ -6,6 +6,7 @@ const vegaCustomClasses = require('../tailwindcss-config/src/vega-custom-classes
module.exports = { module.exports = {
content: [ content: [
join(__dirname, 'src/**/*.{ts,tsx,html,mdx}'), join(__dirname, 'src/**/*.{ts,tsx,html,mdx}'),
join(__dirname, 'src/utils/shared.ts'),
join(__dirname, '.storybook/preview.js'), join(__dirname, '.storybook/preview.js'),
...createGlobPatternsForDependencies(__dirname), ...createGlobPatternsForDependencies(__dirname),
], ],