Skip to content

Commit

Permalink
feat: Improve visibility of card commands button #2127 (#2147)
Browse files Browse the repository at this point in the history
  • Loading branch information
marek-mihok authored Oct 6, 2023
1 parent 45afd23 commit 913a7c4
Show file tree
Hide file tree
Showing 4 changed files with 31 additions and 16 deletions.
17 changes: 9 additions & 8 deletions ui/src/card_menu.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -29,25 +29,26 @@ const
top: 0, right: 0,
$nest: {
'>div:first-child': {
padding: 24,
padding: 12,
paddingTop: 10,
fontSize: 16,
color: cssVar('$text7')
},
},
},
icon: {
userSelect: 'none',
marginRight: -6,
},
target: {
boxSizing: 'border-box',
cursor: 'pointer',
opacity: 0.5,
color: cssVar('$text'),
marginRight: -4,
$nest: {
'&:hover': {
opacity: 1,
color: cssVar('$themePrimary'),
},
},
},
target: {
boxSizing: 'border-box',
cursor: 'pointer',
}
})

Expand Down
3 changes: 3 additions & 0 deletions ui/src/parts/styleConstants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,3 +6,6 @@ export const Z_INDEX = {
TIME_PICKER: 4,
NOTIFICATION_BAR: 5
}

export const CARD_TITLE_PADDING_TOP = 16
export const CARD_TITLE_HEIGHT = 17
14 changes: 10 additions & 4 deletions ui/src/plot.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,8 @@ import { Fmt, parseFormat } from './intl'
import { cards, grid } from './layout'
import { cssVarValue, cssVar, formItemWidth, themeB, themesB } from './theme'
import { bond, wave } from './ui'
import { Command } from './toolbar'
import { CARD_TITLE_HEIGHT, CARD_TITLE_PADDING_TOP } from './parts/styleConstants'

let
cat10 = [
Expand All @@ -38,6 +40,7 @@ let
]



type AnnotationOption = ArcOption | LineOption | TextOption | RegionOption | DataMarkerOption | DataRegionOption

enum SpaceT { CC, DD, TT, CD, DC, TC, CT, TD, DT }
Expand Down Expand Up @@ -1192,13 +1195,16 @@ interface State {
animate?: B
}

export const View = bond(({ name, state, changed }: Model<State>) => {
export const View = bond(({ name, state, changed }: Model<State & { commands?: Command[] }>) => {
const render = () => {
const { title = 'Untitled', plot, data, events, interactions, animate } = state
const { title = 'Untitled', plot, data, events, interactions, animate, commands } = state
return (
<div className={css.card}>
<div className='wave-s12 wave-w6'>{title}</div>
<div className={css.body}>
{title && <div className='wave-s12 wave-w6'>{title}</div>}
<div
className={css.body}
style={{ paddingTop: title ? CARD_TITLE_PADDING_TOP : commands?.length ? CARD_TITLE_PADDING_TOP + CARD_TITLE_HEIGHT : 0 }}
>
<XVisualization model={{ name, plot, data, events, interactions, animate }} />
</div>
</div>
Expand Down
13 changes: 9 additions & 4 deletions ui/src/vega.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@ import { Result } from 'vega-embed'
import { cards } from './layout'
import { formItemWidth } from './theme'
import { bond, debounce } from './ui'
import { Command } from './toolbar'
import { CARD_TITLE_HEIGHT, CARD_TITLE_PADDING_TOP } from './parts/styleConstants'

const
css = stylesheet({
Expand Down Expand Up @@ -142,14 +144,17 @@ interface State {
}

export const
View = bond(({ name, state, changed }: Model<State>) => {
View = bond(({ name, state, changed }: Model<State & { commands?: Command[] }>) => {
const
render = () => {
const { specification, data, title, grammar = 'vega-lite' } = state
const { specification, data, title, grammar = 'vega-lite', commands } = state
return (
<div data-test={name} className={css.card}>
{title && <div className='wave-s12 wave-w6' style={{ marginBottom: 16 }}>{title}</div>}
<div className={css.body}>
{title && <div className='wave-s12 wave-w6'>{title}</div>}
<div
className={css.body}
style={{ paddingTop: title ? CARD_TITLE_PADDING_TOP : commands?.length ? CARD_TITLE_PADDING_TOP + CARD_TITLE_HEIGHT : 0 }}
>
<XVegaVisualization model={{ specification, data, grammar }} />
</div>
</div>
Expand Down

0 comments on commit 913a7c4

Please sign in to comment.