Skip to content

Commit

Permalink
fixes select styles on home page
Browse files Browse the repository at this point in the history
  • Loading branch information
dimaMachina committed Jul 12, 2022
1 parent ae4a9ec commit e707598
Show file tree
Hide file tree
Showing 56 changed files with 101 additions and 107 deletions.
4 changes: 2 additions & 2 deletions .prettierignore
Original file line number Diff line number Diff line change
Expand Up @@ -17,5 +17,5 @@ website/src/pages/docs/config-reference/schema-field.mdx
website/src/pages/docs/getting-started/index.mdx
website/src/pages/docs/guides/graphql-server-apollo-yoga.mdx
website/src/pages/docs/guides/react.mdx
website/src/pages/plugin-hub/index.mdx
website/src/pages/plugin-hub/presets/near-operation-file-preset.mdx
website/src/pages/plugins/index.mdx
website/src/pages/plugins/presets/near-operation-file-preset.mdx
5 changes: 1 addition & 4 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -100,10 +100,7 @@
"packages/**/src/**/*.{ts,tsx}": [
"eslint --fix"
],
"**/*.{ts,tsx,graphql,yml}": [
"prettier --write"
],
"**/*.json": [
"**/*.{js,jsx,cjs,mjs,ts,tsx,graphql,gql,yml,yaml,json,md}": [
"prettier --write"
],
"yarn.lock": [
Expand Down
2 changes: 1 addition & 1 deletion website/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@
"@guild-docs/client": "4.0.0-alpha-977f9d3.0",
"@guild-docs/server": "4.0.0",
"@monaco-editor/react": "4.4.5",
"@theguild/components": "2.0.0-alpha-067b6c4.0",
"@theguild/components": "2.0.0-alpha-8c5e72a.0",
"classnames": "2.3.1",
"date-fns": "2.28.0",
"dedent": "0.7.0",
Expand Down
2 changes: 1 addition & 1 deletion website/src/components/live-demo/Editor.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ const Editor = ({
readOnly?: boolean;
onEdit: (value?: string) => void;
}): ReactElement | null => {
const { theme } = useTheme()
const { theme } = useTheme();
if (!canUseDOM) {
return null;
}
Expand Down
102 changes: 43 additions & 59 deletions website/src/components/live-demo/LiveDemo.tsx
Original file line number Diff line number Diff line change
@@ -1,15 +1,14 @@
import { useState, useEffect, Suspense, Fragment, ReactElement } from 'react';
import { useState, useEffect, Suspense, ReactElement } from 'react';
import { load } from 'js-yaml';
import dynamic from 'next/dynamic';
import Image from 'next/image';
import { useTheme } from 'next-themes';
import { useTheme } from '@theguild/components';
import Select from 'react-select';
import { EXAMPLES, EXAMPLES_ICONS } from './examples';
import { getMode } from './formatter';
import { generate } from './generate';
import { Loading } from '../ui/Loading';
import LiveDemoEditors from './LiveDemoEditors';
import classes from './styles.module.css';

const ErrorBoundary = dynamic(import('./ErrorBoundary'), { ssr: false });

Expand Down Expand Up @@ -49,8 +48,8 @@ const DEFAULT_EXAMPLE = {
} as const;

export const LiveDemo = (): ReactElement => {
const { theme } = useTheme()
const isDarkTheme = theme === 'dark'
const { theme } = useTheme();
const isDarkTheme = theme === 'dark';
const [template, setTemplate] = useState(`${DEFAULT_EXAMPLE.catName}__${DEFAULT_EXAMPLE.index}`);
const [schema, setSchema] = useState(EXAMPLES[DEFAULT_EXAMPLE.catName][DEFAULT_EXAMPLE.index].schema);
const [documents, setDocuments] = useState(EXAMPLES[DEFAULT_EXAMPLE.catName][DEFAULT_EXAMPLE.index].documents);
Expand Down Expand Up @@ -83,60 +82,45 @@ export const LiveDemo = (): ReactElement => {

return (
<div className="hidden lg:!block">
<div className={classes.picker}>
<h3>Choose Live Example: </h3>
<div>
<Select
isSearchable={false}
styles={{
menu: styles => ({ ...styles, ...(isDarkTheme && { backgroundColor: 'black' }) }),
control: styles => ({ ...styles, ...(isDarkTheme && { backgroundColor: 'black' }) }),
container: styles => ({
...styles,
display: 'inline-block',
width: '100%',
textAlign: 'left',
}),
option: (styles, { isFocused }) => ({
...styles,
fontSize: 13,
...(isDarkTheme && isFocused && { backgroundColor: 'gray' }),
}),
singleValue: styles => ({
...styles,
width: '100%',
...(isDarkTheme && { color: 'white' }),
}),
}}
isMulti={false}
isClearable={false}
onChange={e => changeTemplate(e.selectId)}
getOptionValue={o => o.selectId}
getOptionLabel={o => (
<>
<span>{o.name}</span>
<span className={classes.exampleTags}>
{o.tags?.map((t, index) => {
const icon = EXAMPLES_ICONS[t];
const key = `${o.name}_${index}`;
return icon ? (
<Fragment key={key}>
<Image priority height={18} width={18} alt={icon.alt} src={icon.src} />
&nbsp;
</Fragment>
) : (
<span key={key} className={classes.exampleTag}>
{t}
</span>
);
})}
</span>
</>
)}
defaultValue={groupedExamples[0].options[0]}
options={groupedExamples}
/>
</div>
<div className="mx-auto mb-4 w-1/2">
<h3 className="mb-2 text-center">Choose Live Example:</h3>
<Select
isSearchable={false}
className="
rounded-md
[&>div]:dark:bg-black
[&>div>div>div]:dark:text-gray-200
"
styles={{
option: (styles, { isFocused }) => ({
...styles,
fontSize: 13,
...(isFocused && isDarkTheme && { backgroundColor: 'gray' }),
}),
}}
isMulti={false}
isClearable={false}
onChange={e => changeTemplate(e.selectId)}
getOptionValue={o => o.selectId}
getOptionLabel={o => (
<div className="flex items-center justify-end gap-1.5">
<span className="mr-auto">{o.name}</span>
{o.tags?.map((t, index) => {
const icon = EXAMPLES_ICONS[t];
const key = `${o.name}_${index}`;
return icon ? (
<Image key={key} priority height={18} width={18} alt={icon.alt} src={icon.src} />
) : (
<span key={key} className="rounded-lg bg-gray-200 px-2 px-1 text-xs text-gray-800">
{t}
</span>
);
})}
</div>
)}
defaultValue={groupedExamples[0].options[0]}
options={groupedExamples}
/>
</div>
<div className="flex border-y border-gray-300">
<ErrorBoundary>
Expand Down
33 changes: 0 additions & 33 deletions website/src/components/live-demo/styles.module.css
Original file line number Diff line number Diff line change
@@ -1,43 +1,10 @@
@import url('https://fonts.googleapis.com/css2?family=Inconsolata&display=swap');

.picker {
padding-left: 30px;
padding-right: 30px;
padding-bottom: 5px;
margin: 30px auto 0 auto;
text-align: center;
width: 50%;
}

.exampleDesc {
font-size: 0.9em;
border-left: 10px #f1f1f1 solid;
padding-left: 10px;
margin-top: 10px;
text-align: left;
}

.react-monaco-editor-container,
.monaco-editor {
height: 400px;
}

.exampleTag {
background-color: gainsboro;
border-radius: 10px;
font-size: 11px;
padding: 3px 5px 3px 5px;
color: black !important;
margin-right: 3px;
margin-left: 3px;
}

.exampleTags {
padding-right: 20px;
float: right;
display: flex;
}

.column {
align-self: stretch;
flex-flow: column;
Expand Down
3 changes: 1 addition & 2 deletions website/src/pages/_app.tsx
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@
import { ReactElement } from 'react';
import Script from 'next/script';
import { AppProps } from 'next/app';
import { ThemeProvider } from 'next-themes';
import { useGoogleAnalytics } from '@guild-docs/client';
import { Header, FooterExtended } from '@theguild/components';
import { Header, ThemeProvider, FooterExtended } from '@theguild/components';

import 'nextra-theme-docs/style.css';
import '../../public/style.css';
Expand Down
2 changes: 1 addition & 1 deletion website/src/pages/docs/custom-codegen/contributing.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -261,7 +261,7 @@ const PACKAGES: Package<Tags>[] = [
title: 'my-plugin', // page title
npmPackage: '@graphql-codegen/my-plugin', // name of the npm package
iconUrl: '/assets/img/icons/codegen.svg', // you can specify a custom icon, or use codegen's
tags: ['plugin', 'utilities'], // add tags for the search engine
tags: ['plugin', 'utilities'] // add tags for the search engine
}
// …
]
Expand Down
1 change: 1 addition & 0 deletions website/src/pages/plugins/c-sharp/c-sharp-operations.mdx
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
---
title: c-sharp-operations
---

import { PackageApiDocs, PackageHeader } from '@/components'
import { getNpmInfo } from '@/lib/get-npm-info'

Expand Down
1 change: 1 addition & 0 deletions website/src/pages/plugins/flow/flow-operations.mdx
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
---
title: flow-operations
---

import { PackageApiDocs, PackageHeader } from '@/components'
import { getNpmInfo } from '@/lib/get-npm-info'

Expand Down
1 change: 1 addition & 0 deletions website/src/pages/plugins/flow/flow-resolvers.mdx
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
---
title: flow-resolvers
---

import Callout from 'nextra-theme-docs/callout'
import { PackageApiDocs, PackageHeader } from '@/components'
import { getNpmInfo } from '@/lib/get-npm-info'
Expand Down
1 change: 1 addition & 0 deletions website/src/pages/plugins/java/java-apollo-android.mdx
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
---
title: java-apollo-android
---

import Callout from 'nextra-theme-docs/callout'
import { PackageApiDocs, PackageHeader, PackageCmd } from '@/components'
import { getNpmInfo } from '@/lib/get-npm-info'
Expand Down
1 change: 1 addition & 0 deletions website/src/pages/plugins/java/java-resolvers.mdx
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
---
title: java-resolvers
---

import Callout from 'nextra-theme-docs/callout'
import { PackageApiDocs, PackageHeader } from '@/components'
import { getNpmInfo } from '@/lib/get-npm-info'
Expand Down
1 change: 1 addition & 0 deletions website/src/pages/plugins/java/java.mdx
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
---
title: java
---

import Callout from 'nextra-theme-docs/callout'
import { PackageApiDocs, PackageHeader } from '@/components'
import { getNpmInfo } from '@/lib/get-npm-info'
Expand Down
1 change: 1 addition & 0 deletions website/src/pages/plugins/java/kotlin.mdx
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
---
title: kotlin
---

import Callout from 'nextra-theme-docs/callout'
import { PackageApiDocs, PackageHeader, PackageCmd } from '@/components'
import { getNpmInfo } from '@/lib/get-npm-info'
Expand Down
1 change: 1 addition & 0 deletions website/src/pages/plugins/other/add.mdx
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
---
title: add
---

import { PackageApiDocs, PackageHeader } from '@/components'
import { getNpmInfo } from '@/lib/get-npm-info'

Expand Down
1 change: 1 addition & 0 deletions website/src/pages/plugins/other/fragment-matcher.mdx
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
---
title: fragment-matcher
---

import Callout from 'nextra-theme-docs/callout'
import { Tabs, Tab } from 'nextra-theme-docs/tabs'
import { PackageApiDocs, PackageHeader } from '@/components'
Expand Down
1 change: 1 addition & 0 deletions website/src/pages/plugins/other/hasura-allow-list.mdx
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
---
title: hasura-allow-list
---

import { PackageApiDocs, PackageHeader } from '@/components'
import { getNpmInfo } from '@/lib/get-npm-info'

Expand Down
1 change: 1 addition & 0 deletions website/src/pages/plugins/other/introspection.mdx
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
---
title: introspection
---

import { PackageApiDocs, PackageHeader } from '@/components'
import { getNpmInfo } from '@/lib/get-npm-info'

Expand Down
1 change: 1 addition & 0 deletions website/src/pages/plugins/other/jsdoc.mdx
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
---
title: jsdoc
---

import { PackageHeader } from '@/components'
import { getNpmInfo } from '@/lib/get-npm-info'

Expand Down
1 change: 1 addition & 0 deletions website/src/pages/plugins/other/reason-client.mdx
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
---
title: reason-client
---

import { PackageHeader } from '@/components'
import { getNpmInfo } from '@/lib/get-npm-info'

Expand Down
1 change: 1 addition & 0 deletions website/src/pages/plugins/other/schema-ast.mdx
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
---
title: schema-ast
---

import { PackageApiDocs, PackageHeader } from '@/components'
import { getNpmInfo } from '@/lib/get-npm-info'

Expand Down
1 change: 1 addition & 0 deletions website/src/pages/plugins/other/time.mdx
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
---
title: time
---

import { PackageApiDocs, PackageHeader } from '@/components'
import { getNpmInfo } from '@/lib/get-npm-info'

Expand Down
1 change: 1 addition & 0 deletions website/src/pages/plugins/other/urql-introspection.mdx
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
---
title: urql-introspection
---

import Callout from 'nextra-theme-docs/callout'
import { PackageApiDocs, PackageHeader } from '@/components'
import { getNpmInfo } from '@/lib/get-npm-info'
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
---
title: gql-tag-operations-preset
---

import Callout from 'nextra-theme-docs/callout'
import { PackageApiDocs, PackageHeader } from '@/components'
import { getNpmInfo } from '@/lib/get-npm-info'
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
---
title: graphql-modules-preset
---

import Callout from 'nextra-theme-docs/callout'
import { PackageApiDocs, PackageHeader } from '@/components'
import { getNpmInfo } from '@/lib/get-npm-info'
Expand Down
1 change: 1 addition & 0 deletions website/src/pages/plugins/presets/import-types-preset.mdx
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
---
title: import-types-preset
---

import { PackageApiDocs, PackageHeader } from '@/components'
import { getNpmInfo } from '@/lib/get-npm-info'

Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
---
title: near-operation-file-preset
---

import Callout from 'nextra-theme-docs/callout'
import { PackageApiDocs, PackageHeader } from '@/components'
import { getNpmInfo } from '@/lib/get-npm-info'
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
---
title: named-operations-object
---

import { PackageApiDocs, PackageHeader } from '@/components'
import { getNpmInfo } from '@/lib/get-npm-info'

Expand Down
Loading

0 comments on commit e707598

Please sign in to comment.