Skip to content

Commit

Permalink
#208 Sign in guards WIP
Browse files Browse the repository at this point in the history
  • Loading branch information
joepio committed Oct 25, 2022
1 parent d3db530 commit 498cfcf
Show file tree
Hide file tree
Showing 13 changed files with 513 additions and 270 deletions.
14 changes: 11 additions & 3 deletions data-browser/src/components/CodeBlock.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,11 @@ import { Button } from './Button';
interface CodeBlockProps {
content?: string;
loading?: boolean;
wrapContent?: boolean;
}

export function CodeBlock({ content, loading }: CodeBlockProps) {
/** Codeblock with copy feature */
export function CodeBlock({ content, loading, wrapContent }: CodeBlockProps) {
const [isCopied, setIsCopied] = useState<string | undefined>(undefined);

function copyToClipboard() {
Expand All @@ -19,7 +21,7 @@ export function CodeBlock({ content, loading }: CodeBlockProps) {
}

return (
<CodeBlockStyled data-code-content={content}>
<CodeBlockStyled data-code-content={content} wrapContent={wrapContent}>
{loading ? (
'loading...'
) : (
Expand All @@ -46,7 +48,11 @@ export function CodeBlock({ content, loading }: CodeBlockProps) {
);
}

export const CodeBlockStyled = styled.pre`
interface Props {
wrapContent?: boolean;
}

export const CodeBlockStyled = styled.pre<Props>`
position: relative;
background-color: ${p => p.theme.colors.bg1};
border-radius: ${p => p.theme.radius};
Expand All @@ -55,4 +61,6 @@ export const CodeBlockStyled = styled.pre`
font-family: monospace;
width: 100%;
overflow-x: auto;
word-wrap: ${p => (p.wrapContent ? 'break-word' : 'initial')};
white-space: ${p => (p.wrapContent ? 'pre-wrap' : 'initial')};
`;
14 changes: 7 additions & 7 deletions data-browser/src/components/Dialog/useDialog.tsx
Original file line number Diff line number Diff line change
@@ -1,16 +1,16 @@
import { useCallback, useMemo, useState } from 'react';
import { InternalDialogProps } from './index';

export type UseDialogReturnType = [
export type UseDialogReturnType = {
/** Props meant to pass to a {@link Dialog} component */
dialogProps: InternalDialogProps,
dialogProps: InternalDialogProps;
/** Function to show the dialog */
show: () => void,
show: () => void;
/** Function to close the dialog */
close: () => void,
close: () => void;
/** Boolean indicating wether the dialog is currently open */
isOpen: boolean,
];
isOpen: boolean;
};

/** Sets up state, and functions to use with a {@link Dialog} */
export const useDialog = (): UseDialogReturnType => {
Expand Down Expand Up @@ -40,5 +40,5 @@ export const useDialog = (): UseDialogReturnType => {
[showDialog, close, handleClosed],
);

return [dialogProps, show, close, visible];
return { dialogProps, show, close, isOpen: visible };
};
Loading

0 comments on commit 498cfcf

Please sign in to comment.