Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
6 changes: 6 additions & 0 deletions rspack.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -89,9 +89,15 @@ module.exports = (env, options) => {
],
type: 'javascript/auto',
},
{
test: /\.svg$/,
resourceQuery: /raw/,
type: 'asset/source',
},
// Asset files
{
test: /\.(png|svg|jpg|jpeg|ico|ttf|webp|eot|woff|webm|mp4|wav)(\?.*)?$/,
resourceQuery: { not: [/raw/] },
type: 'asset/resource',
},
// Regular CSS/SCSS files
Expand Down
2 changes: 1 addition & 1 deletion src/cm/themes/noctisLilac.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ export const config = {
cursor: "#5c49e9",
dropdownBackground: "#f2f1f8",
dropdownBorder: "#e1def3",
activeLine: "#e1def3",
activeLine: "#e1def355",
lineNumber: "#0c006b70",
lineNumberActive: "#0c006b",
matchingBracket: "#d5d1f2",
Expand Down
17 changes: 16 additions & 1 deletion src/dialogs/loader.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,13 @@ import DOMPurify from "dompurify";
import Ref from "html-tag-js/ref";
import actionStack from "lib/actionStack";
import restoreTheme from "lib/restoreTheme";
import tailSpinSvg from "res/tail-spin.svg?raw";

let loaderIsImmortal = false;
let onCancelCallback = null;
let $currentDialog = null;
let $currentMask = null;
const titleLoaderId = "__title-loader";

/**
* @typedef {object} LoaderOptions
Expand Down Expand Up @@ -51,7 +53,7 @@ function create(titleText, message = "", options = {}) {
{titleText}
</strong>
<span className="message loader">
<span className="loader"></span>
<span className="loader" innerHTML={tailSpinSvg}></span>
<div
ref={$message}
className="message"
Expand Down Expand Up @@ -96,6 +98,18 @@ function create(titleText, message = "", options = {}) {
};
}

function createTitleLoader() {
const $titleLoader = tag.get(`#${titleLoaderId}`) || (
<span id={titleLoaderId} innerHTML={tailSpinSvg}></span>
);

if (!$titleLoader.isConnected) {
app.append($titleLoader);
}

return $titleLoader;
}

/**
* Removes the loader from DOM permanently
*/
Expand Down Expand Up @@ -159,6 +173,7 @@ function showTitleLoader(immortal = false) {
}

setTimeout(() => {
createTitleLoader();
app.classList.remove("title-loading-hide");
app.classList.add("title-loading");
}, 0);
Expand Down
15 changes: 12 additions & 3 deletions src/dialogs/style.scss
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
@use "../styles/mixins.scss";

.prompt {
position: fixed;
left: 50%;
Expand Down Expand Up @@ -285,8 +283,19 @@
align-items: center;

.loader {
@include mixins.circular-loader(30px);
width: 30px;
height: 30px;
color: rgb(153, 153, 255);
color: var(--primary-color);
display: flex;
flex-shrink: 0;
margin: 0 10px;

svg {
width: 100%;
height: 100%;
display: block;
}
}

.message {
Expand Down
5 changes: 3 additions & 2 deletions src/lib/showFileInfo.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import fsOperation from "fileSystem";
import dialog from "dialogs/dialog";
import loader from "dialogs/loader";
import { filesize } from "filesize";
import mustache from "mustache";
import helpers from "utils/helpers";
Expand All @@ -13,7 +14,7 @@ import settings from "./settings";
*/
export default async function showFileInfo(url) {
if (!url) url = editorManager.activeFile.uri;
app.classList.add("title-loading");
loader.showTitleLoader();
try {
const fs = fsOperation(url);
const stats = await fs.stat();
Expand Down Expand Up @@ -65,5 +66,5 @@ export default async function showFileInfo(url) {
helpers.error(err);
}

app.classList.remove("title-loading");
loader.removeTitleLoader();
}
30 changes: 20 additions & 10 deletions src/main.scss
Original file line number Diff line number Diff line change
Expand Up @@ -47,38 +47,48 @@ body {
box-shadow: none !important;
}

#__title-loader {
display: none;
}

&:not(.loading).title-loading {
&.title-loading-hide {
&::after {
background-image: none;
#__title-loader {
transform: translateX(-50%) translateY(-100%) scale3d(0.5, 0.5, 1);
opacity: 0;
animation: hide-loader 100ms ease-in 1;
}
}

&::after {
content: "";
background-color: #3333ff;
background-color: var(--primary-color);
#__title-loader {
align-items: center;
background-color: #ffffff;
background-color: var(--popup-background-color);
border-radius: 50%;
color: #9999ff;
color: var(--popup-text-color);
Comment thread
deadlyjack marked this conversation as resolved.
display: flex;
justify-content: center;
position: fixed;
height: 40px;
width: 40px;
top: 6px;
left: 50%;
transform: translateX(-50%);
background-image: url(res/tail-spin.svg);
background-repeat: no-repeat;
background-position: center;
background-size: 30px;
box-shadow: 0 0 4px 0 rgba(0, 0, 0, 0.2);
box-shadow: 0 0 4px 0 var(--box-shadow-color);
border: solid 1px transparent;
border: solid 1px var(--popup-border-color);
animation: appear 100ms ease-out 1;
box-sizing: border-box;
pointer-events: none;
z-index: 999;

svg {
width: 30px;
height: 30px;
display: block;
}
}
}

Expand Down
14 changes: 7 additions & 7 deletions src/res/tail-spin.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
25 changes: 4 additions & 21 deletions src/theme/list.js
Original file line number Diff line number Diff line change
@@ -1,10 +1,8 @@
import fsOperation from "fileSystem";
import fonts from "lib/fonts";
import settings from "lib/settings";
import { isDeviceDarkTheme } from "lib/systemConfiguration";
import { updateActiveTerminals } from "settings/terminalSettings";
import color from "utils/color";
import Url from "utils/Url";
import fonts from "../lib/fonts";
import settings from "../lib/settings";
import { updateActiveTerminals } from "../settings/terminalSettings";
import ThemeBuilder from "./builder";
import themes, { updateSystemTheme } from "./preInstalled";

Expand Down Expand Up @@ -86,9 +84,6 @@ export async function apply(id, init) {
}

themeApplied = true;
const loaderFile = Url.join(ASSETS_DIRECTORY, "res/tail-spin.svg");
const svgName = "__tail-spin__.svg";
const img = Url.join(DATA_STORAGE, svgName);
const theme = get(id);
const $style = document.head.get("style#app-theme") ?? (
<style id="app-theme"></style>
Expand Down Expand Up @@ -127,6 +122,7 @@ export async function apply(id, init) {
updateActiveTerminals("theme", theme.preferredTerminalTheme);
}
}

localStorage.__primary_color = theme.primaryColor;
document.body.setAttribute("theme-type", theme.type);
$style.textContent = theme.css;
Expand All @@ -144,19 +140,6 @@ export async function apply(id, init) {
}, 1000);
firstTime = false;
}

try {
let fs = fsOperation(loaderFile);
const svg = await fs.readFile("utf8");

fs = fsOperation(img);
if (!(await fs.exists())) {
await fsOperation(DATA_STORAGE).createFile(svgName);
}
await fs.writeFile(svg.replace(/#fff/g, theme.primaryColor));
} catch (error) {
window.log("error", error);
}
}

/**
Expand Down
30 changes: 18 additions & 12 deletions webpack.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -30,18 +30,24 @@ module.exports = (env, options) => {
test: /\.(hbs|md)$/,
use: ['raw-loader'],
},
{
test: /\.m.(sa|sc|c)ss$/,
use: [
'raw-loader',
'postcss-loader',
'sass-loader',
],
},
{
test: /\.(png|svg|jpg|jpeg|ico|ttf|webp|eot|woff|webm|mp4|webp|wav)(\?.*)?$/,
type: "asset/resource",
},
{
test: /\.m.(sa|sc|c)ss$/,
use: [
'raw-loader',
'postcss-loader',
'sass-loader',
],
},
{
test: /\.svg$/,
resourceQuery: /raw/,
type: 'asset/source',
},
{
test: /\.(png|svg|jpg|jpeg|ico|ttf|webp|eot|woff|webm|mp4|webp|wav)(\?.*)?$/,
resourceQuery: { not: [/raw/] },
type: "asset/resource",
},
{
test: /(?<!\.m)\.(sa|sc|c)ss$/,
use: [
Expand Down