Skip to content

Commit

Permalink
Create shared panels component
Browse files Browse the repository at this point in the history
  • Loading branch information
mattseddon committed May 30, 2023
1 parent 36bd10b commit f6c5d69
Show file tree
Hide file tree
Showing 12 changed files with 92 additions and 118 deletions.
37 changes: 0 additions & 37 deletions webview/src/setup/components/experiments/CodeSlider.tsx

This file was deleted.

25 changes: 14 additions & 11 deletions webview/src/setup/components/experiments/DvcLiveExamples.tsx
Original file line number Diff line number Diff line change
@@ -1,33 +1,36 @@
/* eslint-disable @typescript-eslint/no-unsafe-call */
import React from 'react'
import { CodeSlider } from './CodeSlider'
import styles from './styles.module.scss'
import pyTorch from '../../snippets/pyTorch.py'
import huggingFace from '../../snippets/huggingFace.py'
import keras from '../../snippets/keras.py'
import pythonApi from '../../snippets/pythonApi.py'
import { CodeBlock } from '../shared/CodeBlock'
import { Panels } from '../shared/Panels'

const PythonCodeBlock = ({ children }: { children: string }) => (
<CodeBlock language="python">{children}</CodeBlock>
)

export const DvcLiveExamples: React.FC = () => {
return (
<CodeSlider
codeBlocks={[
<Panels
className={styles.dvcLiveExamples}
panels={[
{
children: pyTorch.toString(),
language: 'python',
children: <PythonCodeBlock>{pyTorch.toString()}</PythonCodeBlock>,
title: 'PyTorch Lightning'
},
{
children: huggingFace.toString(),
language: 'python',
children: <PythonCodeBlock>{huggingFace.toString()}</PythonCodeBlock>,
title: 'Hugging Face'
},
{
children: keras.toString(),
language: 'python',
children: <PythonCodeBlock>{keras.toString()}</PythonCodeBlock>,
title: 'Keras'
},
{
children: pythonApi.toString(),
language: 'python',
children: <PythonCodeBlock>{pythonApi.toString()}</PythonCodeBlock>,
title: 'General Python API'
}
]}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
@import '../../../shared/variables';

.codeSlider {
.dvcLiveExamples {
margin-top: 40px;

vscode-panels {
Expand Down
4 changes: 2 additions & 2 deletions webview/src/setup/components/remotes/Connect.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import React from 'react'
import { StorageSlider } from './StorageSlider'
import { SupportedStorage } from './SupportedStorage'
import { EmptyState } from '../../../shared/components/emptyState/EmptyState'
import { StartButton } from '../../../shared/components/button/StartButton'
import { addRemote } from '../messages'
Expand All @@ -22,6 +22,6 @@ export const Connect: React.FC = () => (
for details on how to connect to a remote
</p>
<StartButton onClick={() => addRemote()} text="Add Remote" />
<StorageSlider />
<SupportedStorage />
</EmptyState>
)
4 changes: 2 additions & 2 deletions webview/src/setup/components/remotes/DvcUninitialized.tsx
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
import React from 'react'
import { StorageSlider } from './StorageSlider'
import { SupportedStorage } from './SupportedStorage'
import { EmptyState } from '../../../shared/components/emptyState/EmptyState'
import { FocusDvcSection } from '../shared/FocusDvcSection'

export const DvcUninitialized: React.FC<{}> = () => (
<EmptyState isFullScreen={false}>
<h1>DVC is not initialized</h1>
<FocusDvcSection />
<StorageSlider />
<SupportedStorage />
</EmptyState>
)
4 changes: 2 additions & 2 deletions webview/src/setup/components/remotes/RemoteDetails.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import React from 'react'
import { RemoteList } from 'dvc/src/setup/webview/contract'
import { StorageSlider } from './StorageSlider'
import { SupportedStorage } from './SupportedStorage'
import { MultiProjectRemotes } from './MultiProjectRemotes'
import { ProjectRemotes } from './ProjectRemotes'
import { EmptyState } from '../../../shared/components/emptyState/EmptyState'
Expand Down Expand Up @@ -34,7 +34,7 @@ export const RemoteDetails: React.FC<{
onClick={removeRemote}
text="Remove"
/>
<StorageSlider />
<SupportedStorage />
</EmptyState>
)
}
4 changes: 2 additions & 2 deletions webview/src/setup/components/remotes/Remotes.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { RemoteList } from 'dvc/src/setup/webview/contract'
import { Connect } from './Connect'
import { DvcUninitialized } from './DvcUninitialized'
import { RemoteDetails } from './RemoteDetails'
import { StorageSlider } from './StorageSlider'
import { SupportedStorage } from './SupportedStorage'
import { CliIncompatible } from '../shared/CliIncompatible'

export const Remotes: React.FC<{
Expand All @@ -14,7 +14,7 @@ export const Remotes: React.FC<{
return (
<CliIncompatible>
<p>Locate DVC to connect to a remote</p>
<StorageSlider />
<SupportedStorage />
</CliIncompatible>
)
}
Expand Down
50 changes: 0 additions & 50 deletions webview/src/setup/components/remotes/StorageSlider.tsx

This file was deleted.

31 changes: 31 additions & 0 deletions webview/src/setup/components/remotes/SupportedStorage.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
import React from 'react'
import styles from './styles.module.scss'
import { AmazonS3 } from './AmazonS3'
import { GoogleCloudStorage } from './GoogleCloudStorage'
import { AzureBlobStorage } from './AzureBlobStorage'
import { OtherStorageTypes } from './OtherStorageTypes'
import { Panels } from '../shared/Panels'

export const SupportedStorage: React.FC = () => (
<Panels
panels={[
{
children: <AmazonS3 />,
title: 'Amazon S3'
},
{
children: <GoogleCloudStorage />,
title: 'Google Cloud Storage'
},
{
children: <AzureBlobStorage />,
title: 'Azure Blob Storage'
},
{
children: <OtherStorageTypes />,
title: 'Other'
}
]}
className={styles.supportedStorage}
/>
)
17 changes: 7 additions & 10 deletions webview/src/setup/components/remotes/styles.module.scss
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,8 @@
text-align: center;
}

.storageSlider {
margin-top: 40px;
.supportedStorage {
margin-top: 20px;

vscode-panels {
width: max-content;
Expand All @@ -44,19 +44,16 @@
}
}

.storageView {
text-align: left;
padding: 0;
width: max-content;
margin: 0 50px;
}

.storageDetails {
background-color: transparent !important;
letter-spacing: 0.04em;
color: $watermark-color;
font-family: sans-serif;
letter-spacing: 0.04em;
line-height: 1.6;
margin: 0 50px;
padding: 0;
text-align: left;
width: max-content;
}

.infoIcon {
Expand Down
2 changes: 1 addition & 1 deletion webview/src/setup/components/shared/CodeBlock.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import React from 'react'
import Highlight, { defaultProps, Language } from 'prism-react-renderer'
import styles from './styles.module.scss'

export interface CodeBlockProps {
interface CodeBlockProps {
language: Language
children: string
inline?: boolean
Expand Down
30 changes: 30 additions & 0 deletions webview/src/setup/components/shared/Panels.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
import {
VSCodePanelTab,
VSCodePanelView,
VSCodePanels
} from '@vscode/webview-ui-toolkit/react'
import React, { ReactNode } from 'react'

interface PanelProps {
panels: { title: string; children: ReactNode }[]
className: string
}

export const Panels: React.FC<PanelProps> = ({ className, panels }) => {
return (
<div className={className}>
<VSCodePanels>
{panels.map(panel => (
<VSCodePanelTab key={`tab-${panel.title}`}>
{panel.title}
</VSCodePanelTab>
))}
{panels.map(panel => (
<VSCodePanelView key={`view-${panel.title}`}>
{panel.children}
</VSCodePanelView>
))}
</VSCodePanels>
</div>
)
}

0 comments on commit f6c5d69

Please sign in to comment.