Skip to content

Commit

Permalink
chore(graph): remove global styles in favor of tailwind (#13882)
Browse files Browse the repository at this point in the history
Co-authored-by: Philip Fulcher <philipfulcher@Philips-MacBook-Air.local>
  • Loading branch information
philipjfulcher and Philip Fulcher committed Dec 16, 2022
1 parent b94c7e5 commit 78f3a3c
Show file tree
Hide file tree
Showing 9 changed files with 34 additions and 37 deletions.
2 changes: 1 addition & 1 deletion graph/client/.storybook/preview.js
@@ -1,4 +1,4 @@
import '../src/styles.scss';
import '../src/styles.css';

import React from 'react';
import { MemoryRouter } from 'react-router-dom';
Expand Down
2 changes: 1 addition & 1 deletion graph/client/project.json
Expand Up @@ -39,7 +39,7 @@
"main": "graph/client/src/main.tsx",
"polyfills": "graph/client/src/polyfills.ts",
"tsConfig": "graph/client/tsconfig.app.json",
"styles": ["graph/client/src/styles.scss"],
"styles": ["graph/client/src/styles.css"],
"scripts": [],
"assets": [],
"webpackConfig": "graph/client/webpack.config.js",
Expand Down
5 changes: 4 additions & 1 deletion graph/client/src/app/shell.tsx
Expand Up @@ -175,7 +175,10 @@ export function Shell(): JSX.Element {
) : null}

<div className="h-full w-full">
<div className="h-full w-full" id="cytoscape-graph"></div>
<div
className="h-full w-full cursor-pointer"
id="cytoscape-graph"
></div>
<TooltipDisplay></TooltipDisplay>

<Tooltip
Expand Down
16 changes: 13 additions & 3 deletions graph/client/src/app/theme-resolver.tsx
Expand Up @@ -7,10 +7,20 @@ export let currentTheme: Theme;

function mediaListener(ev: MediaQueryListEvent) {
const resolver = ev.matches ? 'dark' : 'light';
htmlEl.className = resolver;
toggleHtmlClass(resolver);
currentTheme = resolver;
}

function toggleHtmlClass(theme: Theme) {
if (theme === 'dark') {
htmlEl.classList.add('dark');
htmlEl.classList.remove('light');
} else {
htmlEl.classList.add('light');
htmlEl.classList.remove('dark');
}
}

export function themeInit() {
const theme =
(localStorage.getItem(localStorageThemeKey) as Theme) ?? 'system';
Expand All @@ -25,13 +35,13 @@ export function themeResolver(theme: Theme) {
const darkMedia = window.matchMedia('(prefers-color-scheme: dark)');
if (theme !== 'system') {
darkMedia.removeEventListener('change', mediaListener);
htmlEl.className = theme;
toggleHtmlClass(theme);
currentTheme = theme;
} else {
const resolver = darkMedia.matches ? 'dark' : 'light';

darkMedia.addEventListener('change', mediaListener);
htmlEl.className = resolver;
toggleHtmlClass(resolver);
currentTheme = resolver;
}

Expand Down
8 changes: 5 additions & 3 deletions graph/client/src/index.html
@@ -1,5 +1,5 @@
<!DOCTYPE html>
<html lang="en">
<html lang="en" class="h-full w-full overflow-hidden">
<head>
<meta charset="utf-8" />
<title>Nx Workspace Project Graph</title>
Expand All @@ -25,7 +25,9 @@
</script>
</head>

<body class="bg-white text-slate-500 dark:bg-slate-900 dark:text-slate-400">
<div id="app"></div>
<body
class="h-full w-full overflow-hidden bg-white text-slate-500 dark:bg-slate-900 dark:text-slate-400"
>
<div class="flex h-full w-full overflow-hidden p-0" id="app"></div>
</body>
</html>
8 changes: 8 additions & 0 deletions graph/client/src/styles.css
@@ -0,0 +1,8 @@
@tailwind components;
@tailwind base;
@tailwind utilities;

/** Scrollbars **/
.dark {
color-scheme: dark;
}
26 changes: 0 additions & 26 deletions graph/client/src/styles.scss

This file was deleted.

2 changes: 1 addition & 1 deletion graph/ui-graph/src/lib/nx-project-graph-viz.tsx
Expand Up @@ -114,7 +114,7 @@ export function NxProjectGraphViz({
<div className="not-prose">
<div
ref={containerRef}
className="w-full"
className="w-full cursor-pointer"
style={{ width: '100%', height }}
></div>
{tooltipToRender ? (
Expand Down
2 changes: 1 addition & 1 deletion graph/ui-graph/src/lib/nx-task-graph-viz.tsx
Expand Up @@ -99,7 +99,7 @@ export function NxTaskGraphViz({
<div className="not-prose">
<div
ref={containerRef}
className="w-full"
className="w-full cursor-pointer"
style={{ width: '100%', height }}
></div>
{tooltipToRender ? (
Expand Down

1 comment on commit 78f3a3c

@vercel
Copy link

@vercel vercel bot commented on 78f3a3c Dec 16, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Successfully deployed to the following URLs:

nx-dev – ./

nx-dev-git-master-nrwl.vercel.app
nx-five.vercel.app
nx.dev
nx-dev-nrwl.vercel.app

Please sign in to comment.