A local-first personal finance app
Move view styles into view component (#7412)
Michael Clark6decd9d0f61c
diff --git a/packages/component-library/src/View.tsx b/packages/component-library/src/View.tsxindex d82db8515a..f8cdbd0def 100644--- a/packages/component-library/src/View.tsx+++ b/packages/component-library/src/View.tsx@@ -5,6 +5,21 @@ import { css, cx } from '@emotion/css';import type { CSSProperties } from './styles';+export const viewStyles = css({+ alignItems: 'stretch',+ borderWidth: 0,+ borderStyle: 'solid',+ boxSizing: 'border-box',+ display: 'flex',+ flexDirection: 'column',+ margin: 0,+ padding: 0,+ position: 'relative',+ /* fix flexbox bugs */+ minHeight: 0,+ minWidth: 0,+});+type ViewProps = Omit<HTMLProps<HTMLDivElement>, 'style'> & {className?: string;style?: CSSProperties;@@ -13,19 +28,15 @@ type ViewProps = Omit<HTMLProps<HTMLDivElement>, 'style'> & {};export const View = forwardRef<HTMLDivElement, ViewProps>((props, ref) => {- // The default styles are special-cased and pulled out into static- // styles, and hardcode the class name here. View is used almost- // everywhere and we can avoid any perf penalty that glamor would- // incur.-const { className = '', style, nativeStyle, innerRef, ...restProps } = props;+return (<div{...restProps}ref={innerRef ?? ref}style={nativeStyle}className={cx(- 'view',+ viewStyles,className,style && Object.keys(style).length > 0 ? css(style) : undefined,)}diff --git a/packages/desktop-client/index.html b/packages/desktop-client/index.htmlindex d6b338568e..6f04ac3159 100644--- a/packages/desktop-client/index.html+++ b/packages/desktop-client/index.html@@ -98,21 +98,6 @@overflow: hidden;}- .view {- align-items: stretch;- border-width: 0;- border-style: solid;- box-sizing: border-box;- display: flex;- flex-direction: column;- margin: 0;- padding: 0;- position: relative;- /* fix flexbox bugs */- min-height: 0;- min-width: 0;- }-.cm-theme-dark {height: 100%;}diff --git a/packages/desktop-client/src/components/autocomplete/Autocomplete.tsx b/packages/desktop-client/src/components/autocomplete/Autocomplete.tsxindex 89a8f331e1..ec5bfffba6 100644--- a/packages/desktop-client/src/components/autocomplete/Autocomplete.tsx+++ b/packages/desktop-client/src/components/autocomplete/Autocomplete.tsx@@ -14,7 +14,7 @@ import { Input } from '@actual-app/components/input';import { Popover } from '@actual-app/components/popover';import { styles } from '@actual-app/components/styles';import { theme } from '@actual-app/components/theme';-import { View } from '@actual-app/components/view';+import { View, viewStyles } from '@actual-app/components/view';import { css, cx } from '@emotion/css';import Downshift from 'downshift';import type { StateChangeTypes } from 'downshift';@@ -469,7 +469,7 @@ function SingleAutocomplete<T extends AutocompleteItem>({// can't use a View here, but we can fake it be using the// className<div- className={cx('view', css({ display: 'flex' }))}+ className={cx(viewStyles, css({ display: 'flex' }))}{...containerProps}><View ref={triggerRef} style={{ flexShrink: 0 }}>diff --git a/packages/desktop-client/src/components/budget/BudgetSummaries.tsx b/packages/desktop-client/src/components/budget/BudgetSummaries.tsxindex 6b8eaea800..dace9d099f 100644--- a/packages/desktop-client/src/components/budget/BudgetSummaries.tsx+++ b/packages/desktop-client/src/components/budget/BudgetSummaries.tsx@@ -8,7 +8,7 @@ import React, {} from 'react';import { animated, useSpring } from 'react-spring';-import { View } from '@actual-app/components/view';+import { View, viewStyles } from '@actual-app/components/view';import { css } from '@emotion/css';import { addMonths, subMonths } from 'loot-core/shared/months';@@ -85,7 +85,7 @@ export function BudgetSummaries() {ref={containerRef}><animated.div- className="view"+ className={viewStyles}style={{flexDirection: 'row',width: widthState,diff --git a/upcoming-release-notes/7412.md b/upcoming-release-notes/7412.mdnew file mode 100644index 0000000000..0f5df172e4--- /dev/null+++ b/upcoming-release-notes/7412.md@@ -0,0 +1,6 @@+---+category: Maintenance+authors: [MikesGlitch]+---++Moving View styles into the component library