Skip to content
Open
Show file tree
Hide file tree
Changes from all 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
11 changes: 11 additions & 0 deletions .changeset/angry-planes-look.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
---
"@asyncapi/studio": minor
---
feat: add global dark/light mode theme system

- Added theme toggle button in sidebar with VscSymbolColor icon
- Configured Tailwind `darkMode: 'class'`
- Updated editor, toolbar, navigation, and terminal components with `dark:` variants
- Implemented smooth CSS transitions
- Theme preference persists during session
---
10 changes: 7 additions & 3 deletions apps/studio/.eslintrc
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,12 @@
"env": {
"es6": true,
"browser": true,
"node": true
"node": true,
"es2020": true
},
"globals": {
"globalThis": "readonly"
},
"plugins": ["security"],
"extends":["eslint-config-custom", "eslint-config-custom/react"]
}
"extends":["next/core-web-vitals", "eslint-config-custom", "eslint-config-custom/react"]
}
35 changes: 35 additions & 0 deletions apps/studio/public/img/logo-studio-white.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
8 changes: 4 additions & 4 deletions apps/studio/src/components/Editor/ConvertDropdown.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -24,11 +24,11 @@ export const ConvertDropdown: React.FC = () => {
</button>
</Tooltip>
}
buttonHoverClassName="text-gray-500 hover:text-white"
buttonHoverClassName="text-gray-700 dark:text-gray-500 hover:text-black dark:hover:text-white"
dataTest="button-convert-dropdown"
>
<ul className="bg-gray-800 text-md text-white">
<li className="hover:bg-gray-900">
<ul className="bg-slate-200 dark:bg-gray-800 text-md text-black dark:text-white">
<li className="hover:bg-slate-300 dark:hover:bg-gray-900">
<button
type="button"
className="px-4 py-1 w-full text-left text-sm rounded-md focus:outline-none transition ease-in-out duration-150 disabled:cursor-not-allowed"
Expand Down Expand Up @@ -62,7 +62,7 @@ export const ConvertDropdown: React.FC = () => {
Convert to {language === 'yaml' ? 'JSON' : 'YAML'}
</button>
</li>
<li className="hover:bg-gray-900">
<li className="hover:bg-slate-300 dark:hover:bg-gray-900">
<button
type="button"
className="px-4 py-1 w-full text-left text-sm rounded-md focus:outline-none transition ease-in-out duration-150"
Expand Down
4 changes: 2 additions & 2 deletions apps/studio/src/components/Editor/EditorSidebar.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -27,11 +27,11 @@ export const EditorSidebar: React.FunctionComponent<

return (
<div
className="flex flex-row items justify-between bg-gray-800 border-b border-gray-700 text-sm"
className="flex flex-row items justify-between bg-slate-200 dark:bg-gray-800 border-b border-black dark:border-gray-700 text-sm"
style={{ height: '30px', lineHeight: '30px' }}
>
<div
className="ml-2 text-gray-500 text-xs italic"
className="ml-2 text-gray-700 dark:text-gray-500 text-xs italic"
style={{ height: '30px', lineHeight: '30px' }}
>
{documentFromText}
Expand Down
8 changes: 4 additions & 4 deletions apps/studio/src/components/Editor/GenerateDropdown.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -23,11 +23,11 @@ export const GenerateDropdown: React.FC = () => {
</button>
</Tooltip>
}
buttonHoverClassName="text-gray-500 hover:text-white"
buttonHoverClassName="text-gray-700 dark:text-gray-500 hover:text-black dark:hover:text-white"
dataTest="button-generate-dropdown"
>
<ul className="bg-gray-800 text-md text-white">
<li className="hover:bg-gray-900">
<ul className="bg-slate-200 dark:bg-gray-800 text-md text-black dark:text-white">
<li className="hover:bg-slate-300 dark:hover:bg-gray-900">
<button
type="button"
className="px-4 py-1 w-full text-left text-sm rounded-md focus:outline-none transition ease-in-out duration-150 disabled:cursor-not-allowed"
Expand All @@ -38,7 +38,7 @@ export const GenerateDropdown: React.FC = () => {
Generate code/docs
</button>
</li>
<li className="hover:bg-gray-900">
<li className="hover:bg-slate-300 dark:hover:bg-gray-900">
<button
type="button"
className="px-4 py-1 w-full text-left text-sm rounded-md focus:outline-none transition ease-in-out duration-150 disabled:cursor-not-allowed"
Expand Down
12 changes: 6 additions & 6 deletions apps/studio/src/components/Editor/ImportDropdown.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -24,11 +24,11 @@ export const ImportDropdown: React.FC = () => {
</button>
</Tooltip>
}
buttonHoverClassName="text-gray-500 hover:text-white"
buttonHoverClassName="text-gray-700 dark:text-gray-500 hover:text-black dark:hover:text-white"
dataTest="button-import-dropdown"
>
<ul className="bg-gray-800 text-md text-white">
<li className="hover:bg-gray-900">
<ul className="bg-slate-200 dark:bg-gray-800 text-md text-black dark:text-white">
<li className="hover:bg-slate-300 dark:hover:bg-gray-900">
<button
type="button"
className="px-4 py-1 w-full text-left text-sm rounded-md focus:outline-none transition ease-in-out duration-150"
Expand All @@ -39,7 +39,7 @@ export const ImportDropdown: React.FC = () => {
</button>
</li>

<li className="hover:bg-gray-900">
<li className="hover:bg-slate-300 dark:hover:bg-gray-900">
<label
className="block px-4 py-1 w-full text-left text-sm rounded-md focus:outline-none transition ease-in-out duration-150 cursor-pointer"
title="Import File"
Expand Down Expand Up @@ -72,7 +72,7 @@ export const ImportDropdown: React.FC = () => {
</label>
</li>

<li className="hover:bg-gray-900">
<li className="hover:bg-slate-300 dark:hover:bg-gray-900">
<button
type="button"
className="px-4 py-1 w-full text-left text-sm rounded-md focus:outline-none transition ease-in-out duration-150"
Expand All @@ -83,7 +83,7 @@ export const ImportDropdown: React.FC = () => {
</button>
</li>

<li className="hover:bg-gray-900">
<li className="hover:bg-slate-300 dark:hover:bg-gray-900">
<button
type="button"
className="px-4 py-1 w-full text-left text-sm rounded-md focus:outline-none transition ease-in-out duration-150"
Expand Down
19 changes: 17 additions & 2 deletions apps/studio/src/components/Editor/MonacoWrapper.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
'use client'
import { useMemo, FunctionComponent } from 'react';
import { useState, useEffect, useMemo, FunctionComponent } from 'react';
import MonacoEditor from '@monaco-editor/react';

import { debounce } from '@/helpers';
Expand All @@ -11,6 +11,21 @@ import type { EditorProps as MonacoEditorProps } from '@monaco-editor/react';
export const MonacoWrapper: FunctionComponent<MonacoEditorProps> = ({
...props
}) => {
const [isDark, setIsDark] = useState(
typeof document !== 'undefined' && document.documentElement.classList.contains('dark')
);

useEffect(() => {
const observer = new MutationObserver(() => {
setIsDark(document.documentElement.classList.contains('dark'));
});
observer.observe(document.documentElement, {
attributes: true,
attributeFilter: ['class'],
});
return () => observer.disconnect();
}, []);

const { editorSvc, parserSvc } = useServices();
const { autoSaving, savingDelay } = useSettingsState(state => state.editor);
const file = useFilesState(state => state.files['asyncapi']);
Expand All @@ -27,7 +42,7 @@ export const MonacoWrapper: FunctionComponent<MonacoEditorProps> = ({
<MonacoEditor
language={file.language}
defaultValue={file.content}
theme="asyncapi-theme"
theme={isDark ? 'asyncapi-theme' : 'vs'}
onMount={editorSvc.onDidCreate.bind(editorSvc)}
onChange={onChange}
options={{
Expand Down
8 changes: 4 additions & 4 deletions apps/studio/src/components/Editor/SaveDropdown.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -22,11 +22,11 @@ export const SaveDropdown: React.FC = () => {
</button>
</Tooltip>
}
buttonHoverClassName="text-gray-500 hover:text-white"
buttonHoverClassName="text-gray-700 dark:text-gray-500 hover:text-black dark:hover:text-white"
dataTest="button-save-dropdown"
>
<ul className="bg-gray-800 text-md text-white">
<li className="hover:bg-gray-900">
<ul className="bg-slate-200 dark:bg-gray-800 text-md text-black dark:text-white">
<li className="hover:bg-slate-300 dark:hover:bg-gray-900">
<button
type="button"
className="px-4 py-1 w-full text-left text-sm rounded-md focus:outline-none transition ease-in-out duration-150 disabled:cursor-not-allowed"
Expand Down Expand Up @@ -60,7 +60,7 @@ export const SaveDropdown: React.FC = () => {
Save as {language === 'yaml' ? 'YAML' : 'JSON'}
</button>
</li>
<li className="hover:bg-gray-900">
<li className="hover:bg-slate-300 dark:hover:bg-gray-900">
<button
type="button"
className="px-4 py-1 w-full text-left text-sm rounded-md focus:outline-none transition ease-in-out duration-150 disabled:cursor-not-allowed"
Expand Down
2 changes: 1 addition & 1 deletion apps/studio/src/components/Editor/ShareButton.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ export const ShareButton: React.FunctionComponent<ShareButtonProps> = () => {
return (
<Tooltip content={'Share link'} placement="top" hideOnClick={true}>
<button className="bg-inherit" onClick={handleShare} data-test="button-share">
<FaShareAlt className="text-gray-500 hover:text-white" />
<FaShareAlt className="text-gray-700 dark:text-gray-500 hover:text-black dark:hover:text-white" />
</button>
</Tooltip>
);
Expand Down
2 changes: 1 addition & 1 deletion apps/studio/src/components/Modals/NewFileModal.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ interface TemplateListItemProps {

const TemplateListItem: FunctionComponent<TemplateListItemProps> = ({ title, description: Description, onClick, isSelected }) => {
const containerStyles = isSelected ? 'border-pink-500' : 'border-gray-200';
const textStyles = isSelected ? 'text-pink-600' : 'text-gray-600';
const textStyles = isSelected ? 'text-pink-600' : 'text-slate-200 dark:text-gray-600';

return (
<button onClick={onClick} key={title} className={`group text-left flex flex-col cursor-pointer rounded-lg p-4 pb-6 border-2 hover:border-pink-500 ${containerStyles}`}>
Expand Down
Loading