Convert more styling to Emotion

This commit is contained in:
Nathan Bierema 2023-12-13 17:41:53 -05:00
parent af0ca8f304
commit 5e589ba80c
4 changed files with 75 additions and 85 deletions

View File

@ -1,5 +1,6 @@
import React, { ReactNode, FormEvent, MouseEvent, ChangeEvent } from 'react'; import React, { ReactNode, FormEvent, MouseEvent, ChangeEvent } from 'react';
import type { DebouncedFunc } from 'lodash'; import type { DebouncedFunc } from 'lodash';
import { css } from '@emotion/react';
import { Select } from '@redux-devtools/ui'; import { Select } from '@redux-devtools/ui';
import { QueryFormValues } from '../types'; import { QueryFormValues } from '../types';
import { StyleUtilsContext } from '../styles/createStylingFromTheme'; import { StyleUtilsContext } from '../styles/createStylingFromTheme';
@ -10,6 +11,17 @@ import { QueryFilters, filterQueryOptions } from '../utils/filters';
import { SortOrderButton } from './SortOrderButton'; import { SortOrderButton } from './SortOrderButton';
import { RegexIcon } from './RegexIcon'; import { RegexIcon } from './RegexIcon';
const srOnlyCss = css({
position: 'absolute',
width: 1,
height: 1,
padding: 0,
margin: '-1px',
overflow: 'hidden',
clip: 'rect(0,0,0,0)',
border: 0,
});
export interface QueryFormProps { export interface QueryFormProps {
values: QueryFormValues; values: QueryFormValues;
searchQueryRegex: RegExp | null; searchQueryRegex: RegExp | null;
@ -145,7 +157,7 @@ export class QueryForm extends React.PureComponent<
borderColor: theme.LIST_BORDER_COLOR, borderColor: theme.LIST_BORDER_COLOR,
})} })}
> >
<label htmlFor={searchId} {...styling('srOnly')}> <label htmlFor={searchId} css={srOnlyCss}>
filter query filter query
</label> </label>
<div {...styling('querySearch')}> <div {...styling('querySearch')}>
@ -177,7 +189,7 @@ export class QueryForm extends React.PureComponent<
<RegexIcon /> <RegexIcon />
</button> </button>
</div> </div>
<label htmlFor={selectId} {...styling('srOnly')}> <label htmlFor={selectId} css={srOnlyCss}>
filter by filter by
</label> </label>
<Select<SelectOption<QueryFilters>> <Select<SelectOption<QueryFilters>>

View File

@ -85,7 +85,7 @@ export class QueryList extends PureComponent<QueryListProps> {
<p <p
css={{ css={{
display: '-webkit-box', display: '-webkit-box',
boxOrient: 'vertical', WebkitBoxOrient: 'vertical',
WebkitLineClamp: 2, WebkitLineClamp: 2,
whiteSpace: 'normal', whiteSpace: 'normal',
overflow: 'hidden', overflow: 'hidden',

View File

@ -27,7 +27,17 @@ export class QueryPreviewHeader extends React.Component<QueryPreviewHeaderProps>
<StyleUtilsContext.Consumer> <StyleUtilsContext.Consumer>
{({ styling }) => ( {({ styling }) => (
<div {...styling('previewHeader')}> <div {...styling('previewHeader')}>
<div {...styling('tabSelector')}> <div
css={{
display: 'flex',
width: '100%',
justifyContent: 'flex-end',
overflow: 'hidden',
'& > *': {
flex: '0 1 auto',
},
}}
>
{tabs.map((tab) => ( {tabs.map((tab) => (
<button <button
type="button" type="button"
@ -36,13 +46,55 @@ export class QueryPreviewHeader extends React.Component<QueryPreviewHeaderProps>
role={'tab'} role={'tab'}
onClick={() => this.handleTabClick(tab)} onClick={() => this.handleTabClick(tab)}
key={tab.value} key={tab.value}
{...styling( css={[
[ (theme) => ({
'selectorButton', cursor: 'pointer',
tab.value === selectedTab && 'selectorButtonSelected', position: 'relative',
], height: '33px',
tab.value === selectedTab, padding: '0 8px',
)} display: 'inline-flex',
alignItems: 'center',
boxShadow: 'none',
outline: 'none',
color: theme.TEXT_COLOR,
borderStyle: 'solid',
borderWidth: '1px',
borderLeftWidth: 0,
'&:first-of-type': {
borderLeftWidth: '1px',
borderTopLeftRadius: '3px',
borderBottomLeftRadius: '3px',
},
'&:last-of-type': {
borderTopRightRadius: '3px',
borderBottomRightRadius: '3px',
},
backgroundColor: theme.TAB_BACK_COLOR,
'&:hover': {
backgroundColor: theme.TAB_BACK_HOVER_COLOR,
},
borderColor: theme.TAB_BORDER_COLOR,
'& > *': {
display: '-webkit-box',
boxOrient: 'vertical',
WebkitLineClamp: 1,
overflow: 'hidden',
wordBreak: 'break-all',
WebkitBoxPack: 'end',
paddingBottom: 0,
},
}),
tab.value === selectedTab &&
((theme) => ({
backgroundColor: theme.TAB_BACK_SELECTED_COLOR,
})),
]}
> >
<span> <span>
{renderTabLabel ? renderTabLabel(tab) : tab.label} {renderTabLabel ? renderTabLabel(tab) : tab.label}

View File

@ -97,80 +97,6 @@ const getSheetFromColorMap = (map: ColorMap) => {
}; };
return { return {
tabSelector: {
display: 'flex',
width: '100%',
justifyContent: 'flex-end',
overflow: 'hidden',
'& > *': {
flex: '0 1 auto',
},
},
srOnly: {
position: 'absolute',
width: 1,
height: 1,
padding: 0,
margin: '-1px',
overflow: 'hidden',
clip: 'rect(0,0,0,0)',
border: 0,
},
selectorButton: {
cursor: 'pointer',
position: 'relative',
height: '33px',
padding: '0 8px',
display: 'inline-flex',
alignItems: 'center',
boxShadow: 'none',
outline: 'none',
color: map.TEXT_COLOR,
'border-style': 'solid',
'border-width': '1px',
'border-left-width': 0,
'&:first-child': {
'border-left-width': '1px',
'border-top-left-radius': '3px',
'border-bottom-left-radius': '3px',
},
'&:last-child': {
'border-top-right-radius': '3px',
'border-bottom-right-radius': '3px',
},
'background-color': map.TAB_BACK_COLOR,
'&:hover': {
'background-color': map.TAB_BACK_HOVER_COLOR,
},
'border-color': map.TAB_BORDER_COLOR,
'& > *': {
display: '-webkit-box',
boxOrient: 'vertical',
'-webkit-line-clamp': 1,
overflow: 'hidden',
wordBreak: 'break-all',
'-webkit-box-pack': 'end',
paddingBottom: 0,
},
},
selectorButtonSmall: {
padding: '0px 8px',
'font-size': '0.8em',
},
selectorButtonSelected: {
'background-color': map.TAB_BACK_SELECTED_COLOR,
},
sortButton: { sortButton: {
display: 'flex', display: 'flex',
justifyContent: 'space-between', justifyContent: 'space-between',