diff --git a/.changeset/kind-glasses-thank.md b/.changeset/kind-glasses-thank.md new file mode 100644 index 0000000..7d0e22b --- /dev/null +++ b/.changeset/kind-glasses-thank.md @@ -0,0 +1,5 @@ +--- +'@envyjs/webui': patch +--- + +Align styles with new design diff --git a/docs/images/envy-example.png b/docs/images/envy-example.png index 9fbae6a..dca9301 100644 Binary files a/docs/images/envy-example.png and b/docs/images/envy-example.png differ diff --git a/packages/webui/src/collector/CollectorClient.ts b/packages/webui/src/collector/CollectorClient.ts index 5d0e7df..9ccf615 100644 --- a/packages/webui/src/collector/CollectorClient.ts +++ b/packages/webui/src/collector/CollectorClient.ts @@ -22,6 +22,8 @@ type WebSocketClientOptions = { const INTERNAL_HTTP_TIMEOUT = 120 * 1000; const initialTraceMap = () => { + // ignore coverage for this line since it's only used in dev + // istanbul ignore next return process.env.DEMO === 'true' ? mockTraceCollection() : new Map(); }; diff --git a/packages/webui/src/components/Authorization.tsx b/packages/webui/src/components/Authorization.tsx index 217c74b..20a86f2 100644 --- a/packages/webui/src/components/Authorization.tsx +++ b/packages/webui/src/components/Authorization.tsx @@ -83,7 +83,7 @@ export default function Authorization({ value }: AuthorizationProps) { return (
{`${type} ${token}`}
;
case TokenState.Decoded:
return (
- {k} | -{value} | +{k} | +{value} |
{name} | -+ {presentationData.map(({ name, color, duration, offset, percentage }) => ( + |
---|---|
{name} | +
{
if (counterElRef.current) {
@@ -78,21 +80,21 @@ export default function TraceDetail() {
}
return (
-
-
+
+
-
-
-
+
+
- {method}
{requestAborted && (
-
+
-
{url}
@@ -115,9 +117,12 @@ export default function TraceDetail() {
+
-
- )}
-
+
+ )}
+
+
) : (
-
-
-
+
+
-
+
{data.map(trace => (
{hasTraces && (
-
-
+
+
Traces: {data.length}
diff --git a/packages/webui/src/components/ui/TraceListHeader.tsx b/packages/webui/src/components/ui/TraceListHeader.tsx
index 36651eb..2ea0652 100644
--- a/packages/webui/src/components/ui/TraceListHeader.tsx
+++ b/packages/webui/src/components/ui/TraceListHeader.tsx
@@ -4,7 +4,7 @@ type TraceListHeaderProps = React.HtmlHTMLAttributes
+
@@ -45,37 +40,10 @@ export default function TraceListRow({ trace }: { trace: Trace }) {
function getResponseStatus(trace: Trace) {
const { statusCode, state } = trace.http || {};
-
if (state === HttpRequestState.Aborted) return 'Aborted';
-
return statusCode;
}
-function indicatorStyle(trace: Trace) {
- const { statusCode, state } = trace.http || {};
-
- if (state === HttpRequestState.Aborted) return 'border-l-gray-500';
-
- if (statusCode) {
- if (statusCode >= 500) return 'border-l-purple-500';
- else if (statusCode >= 400) return 'border-l-red-500';
- else if (statusCode >= 300) return 'border-l-yellow-500';
- else if (statusCode >= 200) return 'border-l-green-500';
- }
-}
-
-function rowStyle(trace: Trace) {
- const { statusCode, state } = trace.http || {};
-
- if (state === HttpRequestState.Aborted) return 'bg-gray-300';
-
- if (statusCode) {
- if (statusCode >= 500) return 'bg-purple-200';
- else if (statusCode >= 400) return 'bg-red-200';
- else if (statusCode >= 300) return 'bg-yellow-200';
- }
-}
-
function formatRequestDuration(trace: Trace) {
return trace.http?.duration ? `${(trace.http.duration / 1000).toFixed(2)}s` :
{children}
);
diff --git a/packages/webui/src/components/ui/TraceListPlaceholder.tsx b/packages/webui/src/components/ui/TraceListPlaceholder.tsx
index a85144b..43c874c 100644
--- a/packages/webui/src/components/ui/TraceListPlaceholder.tsx
+++ b/packages/webui/src/components/ui/TraceListPlaceholder.tsx
@@ -14,7 +14,7 @@ export default function TraceListPlaceholder() {
return (
- {trace.http?.method.toUpperCase()}
-
-
- {getResponseStatus(trace)}
-
+
{hostName && (
-
+
{hostName}
)}
{pathValue}
{data && (
-
+
{data}
)}
diff --git a/packages/webui/src/hooks/useFeatureFlags.ts b/packages/webui/src/hooks/useFeatureFlags.ts
index d5b251d..0766331 100644
--- a/packages/webui/src/hooks/useFeatureFlags.ts
+++ b/packages/webui/src/hooks/useFeatureFlags.ts
@@ -1,5 +1,5 @@
export default function useFeatureFlags() {
return {
- enableThemeSwitcher: true,
+ enableThemeSwitcher: false,
};
}
diff --git a/packages/webui/src/styles/allotment.css b/packages/webui/src/styles/allotment.css
index 8603833..758934e 100644
--- a/packages/webui/src/styles/allotment.css
+++ b/packages/webui/src/styles/allotment.css
@@ -1,5 +1,5 @@
:root {
- --separator-border: rgba(128, 128, 128, 0.35);
+ --separator-border: rgba(181, 185, 196, 1);
}
.allotment-module_splitView__L-yRc {
diff --git a/packages/webui/src/styles/base.css b/packages/webui/src/styles/base.css
index a0a1bb6..f4d738e 100644
--- a/packages/webui/src/styles/base.css
+++ b/packages/webui/src/styles/base.css
@@ -1,3 +1,4 @@
+@import url('https://fonts.googleapis.com/css?family=Roboto:400,600,700|Roboto Mono:400,600,700&display=swap');
@import './allotment.css';
@tailwind base;
@@ -9,71 +10,18 @@ html,
body,
main#root {
@apply h-full;
- @apply bg-gray-200 text-gray-800;
-}
-
-/**
- * Text colors
- */
-.text-primary {
- @apply text-gray-800 dark:text-gray-800;
-}
-
-.text-secondary {
- @apply text-gray-500 dark:text-gray-500;
-}
-
-.text-neutral {
- @apply text-gray-400 dark:text-gray-400;
-}
-
-/**
- * Background colors
- */
-.bg-primary {
- @apply bg-gray-200;
-}
-
-.bg-secondary {
- @apply bg-gray-300;
-}
-
-.bg-neutral {
- @apply bg-white;
-}
-
-/**
- * Border colors
- */
-.border-primary {
- @apply border-gray-400;
-}
-
-.border-secondary {
- @apply border-gray-300;
-}
-
-.border-neutral {
- @apply border-gray-200;
-}
-
-.ring-primary {
- @apply ring-gray-400;
+ @apply bg-manatee-200 text-manatee-950;
}
/**
* Override native elements
*/
-hr {
- @apply block border-0 border-b border-b-gray-400/50 h-0 my-1;
-}
-
::-webkit-scrollbar {
- @apply bg-gray-300 w-2 h-3;
+ @apply bg-transparent w-2 h-3;
}
::-webkit-scrollbar-thumb {
- @apply bg-gray-400;
+ @apply bg-manatee-700;
}
input[type='search']::-webkit-search-decoration,
@@ -101,8 +49,8 @@ input[type='search']::-webkit-search-results-decoration {
.p-cell {
@apply py-1 px-2;
- @apply first:pl-4;
- @apply last:pr-4;
+ @apply first:pl-3;
+ @apply last:pr-3;
}
.absolute-v-center {
@@ -123,7 +71,7 @@ input[type='search']::-webkit-search-results-decoration {
*/
.code {
@apply !font-mono !tracking-normal !break-all;
- @apply text-slate-900;
+ @apply text-manatee-950;
}
.code-inline {
@@ -135,7 +83,7 @@ input[type='search']::-webkit-search-results-decoration {
@apply code;
@apply w-full py-4;
@apply block overflow-auto;
- @apply bg-gray-200;
+ @apply bg-manatee-100;
@apply rounded;
}
@@ -145,3 +93,26 @@ input[type='search']::-webkit-search-results-decoration {
@apply hover:bg-opacity-50 hover:bg-white;
@apply hover:cursor-default;
}
+
+/**
+ * Tables
+ */
+.badge-200 {
+ @apply bg-[#318B47] text-white
+}
+
+.badge-300 {
+ @apply bg-yellow-400 text-white
+}
+
+.badge-400 {
+ @apply bg-[#AC0535] text-white
+}
+
+.badge-500 {
+ @apply bg-[#613C8D] text-white
+}
+
+.badge-abort {
+ @apply bg-manatee-700 text-white
+}
diff --git a/packages/webui/src/systems/GraphQL.tsx b/packages/webui/src/systems/GraphQL.tsx
index b734112..b5a258a 100644
--- a/packages/webui/src/systems/GraphQL.tsx
+++ b/packages/webui/src/systems/GraphQL.tsx
@@ -44,7 +44,7 @@ export default class GraphQLSystem implements System {query}
{query}
- {Component} - > - ) : null; + return Component ? Component : null; } export function ResponseDetailsComponent({ trace }: SystemDetailProps): React.ReactNode { const Component = callOrFallback - {Component} - > - ) : null; + return Component ? Component : null; } diff --git a/packages/webui/src/utils/styles.test.ts b/packages/webui/src/utils/styles.test.ts new file mode 100644 index 0000000..e3b85ce --- /dev/null +++ b/packages/webui/src/utils/styles.test.ts @@ -0,0 +1,35 @@ +import { HttpRequestState } from '@envyjs/core'; + +import { badgeStyle } from './styles'; + +describe('badgeStyle', () => { + const scenarios = [ + { statusCode: 500, bgColor: 'badge-500' }, + { statusCode: 404, bgColor: 'badge-400' }, + { statusCode: 300, bgColor: 'badge-300' }, + { statusCode: 200, bgColor: 'badge-200' }, + ]; + + it.each(scenarios)('should have $bgColor for HTTP $statusCode responses', ({ statusCode, bgColor }) => { + const trace = { + http: { + state: HttpRequestState.Received, + statusCode, + }, + } as any; + + const style = badgeStyle(trace); + expect(style).toEqual(bgColor); + }); + + it('should have badge-abort for aborted HTTP requests', () => { + const trace = { + http: { + state: HttpRequestState.Aborted, + }, + } as any; + + const style = badgeStyle(trace); + expect(style).toEqual('badge-abort'); + }); +}); diff --git a/packages/webui/src/utils/styles.ts b/packages/webui/src/utils/styles.ts new file mode 100644 index 0000000..d85de4f --- /dev/null +++ b/packages/webui/src/utils/styles.ts @@ -0,0 +1,16 @@ +import { HttpRequestState } from '@envyjs/core'; + +import { Trace } from '@/types'; + +export function badgeStyle(trace: Trace) { + const { statusCode, state } = trace.http || {}; + + if (state === HttpRequestState.Aborted) return 'badge-abort'; + + if (statusCode) { + if (statusCode >= 500) return 'badge-500'; + else if (statusCode >= 400) return 'badge-400'; + else if (statusCode >= 300) return 'badge-300'; + else if (statusCode >= 200) return 'badge-200'; + } +} diff --git a/packages/webui/tailwind.config.js b/packages/webui/tailwind.config.js index f27be55..2750995 100644 --- a/packages/webui/tailwind.config.js +++ b/packages/webui/tailwind.config.js @@ -1,4 +1,5 @@ /** @type {import('tailwindcss').Config} */ +const defaultTheme = require('tailwindcss/defaultTheme'); export default { darkMode: ['class'], content: ['./src/index.html', './src/**/*.tsx'], @@ -45,8 +46,12 @@ export default { 950: '#0F1212', }, }, + fontFamily: { + sans: ['Roboto', ...defaultTheme.fontFamily.sans], + mono: ['Roboto Mono', ...defaultTheme.fontFamily.mono], + }, fontSize: { - '2xs': ['0.6rem', '0.9rem'], + '2xs': ['0.625rem', '0.875rem'], }, }, }, |