Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

chore(website): [playground] improve design of error viewer#6738

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Merged
armano2 merged 2 commits intov6fromchore/website-error-viewer-correct-design-issues
Mar 27, 2023
Merged
Show file tree
Hide file tree
Changes fromall commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletionspackages/website/src/components/ErrorsViewer.module.css
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -22,3 +22,11 @@
.fixer {
margin: 0.5rem 0 0.5rem 1.5rem;
}

.errorPre {
background: transparent;
margin: 0;
padding: 0;
white-space: break-spaces;
word-wrap: break-word;
}
53 changes: 18 additions & 35 deletionspackages/website/src/components/ErrorsViewer.tsx
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -5,6 +5,8 @@ import type Monaco from 'monaco-editor';
import React, { useEffect, useState } from 'react';

import styles from './ErrorsViewer.module.css';
import type { AlertBlockProps } from './layout/AlertBlock';
import AlertBlock from './layout/AlertBlock';
import type { ErrorGroup, ErrorItem } from './types';

export interface ErrorsViewerProps {
Expand All@@ -17,13 +19,7 @@ export interface ErrorViewerProps {
readonly type: AlertBlockProps['type'];
}

interface AlertBlockProps {
readonly type: 'danger' | 'warning' | 'note' | 'info' | 'success';
readonly children: React.ReactNode;
readonly fixer?: boolean;
}

interface ErrorBlockProps {
export interface ErrorBlockProps {
readonly item: ErrorItem;
readonly setIsLocked: (value: boolean) => void;
readonly isLocked: boolean;
Expand DownExpand Up@@ -64,14 +60,6 @@ function FixButton(props: FixButtonProps): JSX.Element {
);
}

function AlertBlock(props: AlertBlockProps): JSX.Element {
return (
<div className={`admonition alert alert--${props.type}`}>
<div className="admonition-content">{props.children}</div>
</div>
);
}

function ErrorBlock({
item,
setIsLocked,
Expand All@@ -80,9 +68,9 @@ function ErrorBlock({
return (
<AlertBlock type={severityClass(item.severity)}>
<div className={clsx(!!item.fixer && styles.fixerContainer)}>
<div>
<pre className={styles.errorPre}>
{item.message} {item.location}
</div>
</pre>
{item.fixer && (
<FixButton
disabled={isLocked}
Expand DownExpand Up@@ -112,16 +100,6 @@ function ErrorBlock({
);
}

function SuccessBlock(): JSX.Element {
return (
<AlertBlock type="success">
<div className={styles.fixerContainer}>
<div>All is ok!</div>
</div>
</AlertBlock>
);
}

export function ErrorViewer({
value,
title,
Expand All@@ -134,7 +112,9 @@ export function ErrorViewer({
<div className={styles.fixerContainer}>
<h4>{title}</h4>
</div>
{type === 'danger' ? value.stack : value.message}
<pre className={styles.errorPre}>
{type === 'danger' ? value?.stack : value.message}
</pre>
</AlertBlock>
</div>
</div>
Expand DownExpand Up@@ -170,19 +150,22 @@ export function ErrorsViewer({ value }: ErrorsViewerProps): JSX.Element {
)}
</h4>
{items.map((item, index) => (
<ErrorBlock
isLocked={isLocked}
setIsLocked={setIsLocked}
item={item}
key={index}
/>
<div className="margin-bottom--sm" key={index}>
<ErrorBlock
isLocked={isLocked}
setIsLocked={setIsLocked}
item={item}
/>
</div>
))}
</div>
);
})
) : (
<div className="margin-top--md">
<SuccessBlock />
<AlertBlock type="success">
<div>All is ok!</div>
</AlertBlock>
</div>
)}
</div>
Expand Down
16 changes: 16 additions & 0 deletionspackages/website/src/components/layout/AlertBlock.tsx
View file
Open in desktop
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
import React from 'react';

export interface AlertBlockProps {
readonly type: 'success' | 'info' | 'note' | 'warning' | 'danger';
readonly children: React.ReactNode;
}

function AlertBlock(props: AlertBlockProps): JSX.Element {
return (
<div className={`admonition alert alert--${props.type}`}>
<div className="admonition-content">{props.children}</div>
</div>
);
}

export default AlertBlock;

[8]ページ先頭

©2009-2025 Movatter.jp