Skip to content

Commit

Permalink
fix(vision): fix codemirror autocomplete styling (#2875)
Browse files Browse the repository at this point in the history
  • Loading branch information
sjelfull committed Oct 19, 2021
1 parent f5054ea commit 9b10c55
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 1 deletion.
1 change: 1 addition & 0 deletions packages/@sanity/vision/src/components/QueryEditor.js
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,7 @@ class QueryEditor extends React.PureComponent {

render() {
const options = {
theme: 'default CodeMirror-vision',
lineNumbers: true,
tabSize: 2,
mode: {name: 'javascript', json: true},
Expand Down
2 changes: 2 additions & 0 deletions packages/@sanity/vision/src/components/VisionGui.js
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ import {
TimingsFooter,
TimingsCard,
TimingsTextContainer,
GlobalCodeMirrorStyle,
} from './VisionGui.styled'

/* eslint-disable import/no-unassigned-import, import/no-unresolved */
Expand Down Expand Up @@ -429,6 +430,7 @@ class VisionGui extends React.PureComponent {
sizing="border"
overflow="hidden"
>
<GlobalCodeMirrorStyle />
<Header paddingX={3} paddingY={2}>
<Grid columns={12}>
{/* Dataset selector */}
Expand Down
20 changes: 19 additions & 1 deletion packages/@sanity/vision/src/components/VisionGui.styled.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import styled, {css} from 'styled-components'
import styled, {css, createGlobalStyle} from 'styled-components'
import {Button, Card, Box, Flex, Label, rem} from '@sanity/ui'

export const Root = styled(Card)`
Expand Down Expand Up @@ -67,6 +67,24 @@ export const Root = styled(Card)`
}
`

export const GlobalCodeMirrorStyle = createGlobalStyle`
// This is for the autocomplete menu when you do ctrl-space in in the Query editor
.CodeMirror-hints.CodeMirror-vision {
z-index: 20;
font-family: ${({theme}) => theme.sanity.fonts.code.family};
font-size: ${({theme}) => rem(theme.sanity.fonts.code.sizes[1].fontSize)};
padding: ${({theme}) => rem(theme.sanity.space[2])};
}
.CodeMirror-hint {
padding: ${({theme}) => `${rem(theme.sanity.space[1])} ${rem(theme.sanity.space[1])}`};
}
.CodeMirror-hint-active {
background-color: var(--card-bg-color);
}
`

Root.displayName = 'Root'

export const Header = styled(Card)`
Expand Down

3 comments on commit 9b10c55

@vercel
Copy link

@vercel vercel bot commented on 9b10c55 Oct 19, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Successfully deployed to the following URLs:

studio-workshop – ./dev/workshop

studio-workshop.sanity.build
studio-workshop-git-next.sanity.build

@vercel
Copy link

@vercel vercel bot commented on 9b10c55 Oct 19, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Successfully deployed to the following URLs:

test-studio – ./

test-studio.sanity.build
test-studio-git-next.sanity.build

@vercel
Copy link

@vercel vercel bot commented on 9b10c55 Oct 19, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Successfully deployed to the following URLs:

perf-studio – ./

perf-studio.sanity.build
perf-studio-git-next.sanity.build

Please sign in to comment.