Skip to content

Commit 9a94e6d

Browse files
authored
Version 0.20251207.0.
2 parents 762579e + a5fddc9 commit 9a94e6d

File tree

12 files changed

+157
-40
lines changed

12 files changed

+157
-40
lines changed

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@
2323
"url": "git+https://github.com/opencor/webapp.git"
2424
},
2525
"type": "module",
26-
"version": "0.20251206.2",
26+
"version": "0.20251207.0",
2727
"scripts": {
2828
"archive:web": "bun src/renderer/scripts/archive.web.js",
2929
"build": "electron-vite build",

postcss.config.js

Lines changed: 0 additions & 6 deletions
This file was deleted.

src/main/assets/splashscreen.css

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3,14 +3,16 @@
33
* therefore hard-code colours.
44
*/
55

6-
@import "../../renderer/src/assets/base.css";
7-
86
body {
97
background-color: #ffffff; /* Light version of --p-content-background. */
10-
display: flex;
11-
place-items: center;
12-
place-content: center;
13-
overflow: hidden;
8+
margin: 0;
9+
font-family:
10+
Inter, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Oxygen, Ubuntu, Cantarell, "Fira Sans", "Droid Sans",
11+
"Helvetica Neue", sans-serif;
12+
text-rendering: optimizeLegibility;
13+
-webkit-font-smoothing: antialiased;
14+
-moz-osx-font-smoothing: grayscale;
15+
user-select: none;
1416
line-height: 1.6;
1517
}
1618

src/renderer/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@
3939
},
4040
"./style.css": "./dist/opencor.css"
4141
},
42-
"version": "0.20251206.2",
42+
"version": "0.20251207.0",
4343
"scripts": {
4444
"build": "vite build",
4545
"build:lib": "vite build --config vite.lib.config.ts && cp index.d.ts dist/index.d.ts",

src/renderer/postcss.config.js

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
import autoprefixer from 'autoprefixer';
2+
import tailwindcss from '@tailwindcss/postcss';
3+
import postcssScopePlugin from './scripts/postcss-scope-plugin.js';
4+
5+
// Only apply scoping in library build mode, not in dev/Web mode.
6+
7+
const isLibraryBuild = process.env.npm_lifecycle_event === 'build:lib';
8+
9+
export default {
10+
plugins: [
11+
autoprefixer,
12+
tailwindcss,
13+
...(isLibraryBuild
14+
? [
15+
postcssScopePlugin({
16+
scopeSelector: '.opencor-scoped-styles'
17+
})
18+
]
19+
: [])
20+
]
21+
};
Lines changed: 86 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,86 @@
1+
/**
2+
* PostCSS plugin to scope CSS rules under `.opencor-scoped-styles`. This prevents CSS leakage when OpenCOR is used in
3+
* an application that uses another UI framework than PrimeVue (e.g., Bootstrap, Element Plus, Vuetify).
4+
*/
5+
6+
export default function postcssScopePlugin(opts = {}) {
7+
const scopeSelector = opts.scopeSelector || '.opencor-scoped-styles';
8+
const shouldScope = opts.shouldScope || (() => true);
9+
10+
return {
11+
postcssPlugin: 'postcss-scope-plugin',
12+
13+
Rule(rule) {
14+
// Skip if custom filter says no.
15+
16+
if (!shouldScope(rule)) {
17+
return;
18+
}
19+
20+
// Skip if already scoped.
21+
22+
const selectors = rule.selector.split(',').map((s) => s.trim());
23+
24+
if (selectors.every((s) => s.startsWith(scopeSelector))) {
25+
return;
26+
}
27+
28+
// Skip @-rules (like @keyframes, @media, etc.; they will be handled by their parent).
29+
30+
if (
31+
rule.parent?.type === 'atrule' &&
32+
['keyframes', 'font-face', '-webkit-keyframes'].includes(rule.parent.name)
33+
) {
34+
return;
35+
}
36+
37+
// Handle `:root` specially (convert it to our scope selector).
38+
39+
if (rule.selector === ':root') {
40+
rule.selector = scopeSelector;
41+
42+
return;
43+
}
44+
45+
// Handle `html` and `body` specially (convert them to our scope selector).
46+
47+
if (rule.selector === 'html' || rule.selector === 'body') {
48+
rule.selector = scopeSelector;
49+
50+
return;
51+
}
52+
53+
// Split and scope each selector.
54+
55+
const scopedSelectors = selectors.flatMap((selector) => {
56+
// If a selector starts with a pseudo (like `::before`, `:hover`) then scope it directly.
57+
58+
if (selector.startsWith('::') || (selector.startsWith(':') && !selector.includes('('))) {
59+
return `${scopeSelector}${selector}`;
60+
}
61+
62+
// Handle a universal selector specially (only as a descendant).
63+
64+
if (selector === '*' || selector.startsWith('* ')) {
65+
return `${scopeSelector} ${selector}`;
66+
}
67+
68+
// For simple class/id selectors (like `#app`, `.h-full`), we create both a compound and a descendant. This
69+
// allows utilities to work on the scoped element itself and its children. We only do this for selectors that
70+
// start with . or # and have no spaces.
71+
72+
if ((selector.startsWith('.') || selector.startsWith('#')) && !selector.includes(' ')) {
73+
return [`${scopeSelector}${selector}`, `${scopeSelector} ${selector}`];
74+
}
75+
76+
// For everything else (complex selectors, element selectors), we only create a descendant.
77+
78+
return `${scopeSelector} ${selector}`;
79+
});
80+
81+
rule.selector = scopedSelectors.join(', ');
82+
}
83+
};
84+
}
85+
86+
postcssScopePlugin.postcss = true;

src/renderer/src/assets/app.css

Lines changed: 27 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,37 @@
1-
@import "./base.css";
1+
/**
2+
* Scoped styles to prevent CSS leakage when OpenCOR is used as a Vue 3 component in an application that uses a
3+
* different UI framework (e.g., Bootstrap, Element Plus, Vuetify).
4+
* Note: the order of imports is important to ensure that Tailwind CSS does not override PrimeVue styles.
5+
*/
6+
7+
@import "tailwindcss";
8+
@import "tailwindcss-primeui";
9+
@import "primeicons/primeicons.css";
10+
11+
.opencor-scoped-styles {
12+
container-type: inline-size;
13+
--border-color: var(--p-content-border-color);
14+
15+
font-family:
16+
Inter, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Oxygen, Ubuntu, Cantarell, "Fira Sans", "Droid Sans",
17+
"Helvetica Neue", sans-serif;
18+
text-rendering: optimizeLegibility;
19+
-webkit-font-smoothing: antialiased;
20+
-moz-osx-font-smoothing: grayscale;
21+
user-select: none;
222

3-
body {
423
background-color: var(--p-content-background);
524
color: var(--p-content-color);
625
}
726

8-
a {
27+
.opencor-scoped-styles .p-component {
28+
transition: none !important;
29+
}
30+
31+
.opencor-scoped-styles a {
932
color: var(--p-button-link-color);
1033
}
1134

12-
:focus {
35+
.opencor-scoped-styles :focus {
1336
outline: none !important;
1437
}

src/renderer/src/assets/base.css

Lines changed: 0 additions & 21 deletions
This file was deleted.

src/renderer/src/components/MainMenu.vue

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -224,6 +224,12 @@ if (common.isDesktop()) {
224224
border-bottom: 1px solid var(--border-color);
225225
}
226226
227+
.p-menubar a,
228+
.p-menubar-item-link,
229+
:deep(.p-menubar-item-link) {
230+
color: var(--p-text-color);
231+
}
232+
227233
.p-menubar
228234
> .p-menubar-root-list
229235
> .p-menubar-item

src/renderer/src/components/OpenCOR.vue

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -115,7 +115,6 @@ import firebase from 'firebase/compat/app';
115115
import 'firebase/compat/auth';
116116
import { Octokit } from 'octokit';
117117
*/
118-
import 'primeicons/primeicons.css';
119118
import primeVueConfig from 'primevue/config';
120119
import primeVueConfirmationService from 'primevue/confirmationservice';
121120
import primeVueToastService from 'primevue/toastservice';
@@ -128,7 +127,9 @@ import '../assets/app.css';
128127
import * as common from '../common/common';
129128
import { FULL_URI_SCHEME, SHORT_DELAY, TOAST_LIFE } from '../common/constants';
130129
import { electronApi } from '../common/electronApi';
130+
/*---OPENCOR--- Enable once our GitHub integration is fully ready.
131131
import firebaseConfig, { missingFirebaseKeys } from '../common/firebaseConfig';
132+
*/
132133
import * as locCommon from '../common/locCommon';
133134
import * as vueCommon from '../common/vueCommon';
134135
import type IContentsComponent from '../components/ContentsComponent.vue';

0 commit comments

Comments
 (0)