Skip to content

Commit

Permalink
feat: change font styles
Browse files Browse the repository at this point in the history
  • Loading branch information
zjxxxxxxxxx committed Sep 22, 2023
1 parent fea275c commit bca1675
Show file tree
Hide file tree
Showing 8 changed files with 46 additions and 28 deletions.
5 changes: 5 additions & 0 deletions .changeset/nasty-forks-drop.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@open-editor/client': patch
---

change font styles
5 changes: 5 additions & 0 deletions .changeset/tender-elephants-guess.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@open-editor/shared': patch
---

add type uilt 'isBol'
2 changes: 1 addition & 1 deletion packages/client/src/elements/defineInspectElement.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ export interface HTMLInspectElement extends HTMLElement {}
const CSS = `
* {
box-sizing: content-box;
font-family: Inter, system-ui, Avenir, Helvetica, Arial, sans-serif;
font-family: Menlo, Monaco, 'Courier New', monospace;
line-height: 1.5;
font-weight: 400;
}
Expand Down
3 changes: 2 additions & 1 deletion packages/client/src/elements/defineTooltipElement.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,9 @@ const CSS = `
will-change: visibility, top, left;
}
.element {
color: var(--element);
font-size: 14px;
font-weight: 400;
color: var(--element);
}
.component {
font-size: 16px;
Expand Down
22 changes: 13 additions & 9 deletions packages/client/src/elements/defineTreeElement.ts
Original file line number Diff line number Diff line change
Expand Up @@ -49,9 +49,9 @@ const CSS = `
}
.line {
position: absolute;
left: 18px;
left: 17px;
top: 22px;
opacity: 0.4;
opacity: 0.1;
width: 1px;
height: calc(100% - 44px);
background: var(--green);
Expand All @@ -66,11 +66,14 @@ const CSS = `
}
.title {
padding-bottom: 12px;
font-size: 16px;
font-weight: 500;
color: var(--green);
}
.element {
color: var(--element);
font-size: 14px;
font-weight: 400;
color: var(--element);
}
.empty {
color: var(--red);
Expand All @@ -82,25 +85,26 @@ const CSS = `
opacity: 1;
}
.tag[data-file]:hover ~ .line {
opacity: 0.8;
opacity: 0.6;
}
.msg {
font-size: 14px;
font-weight: 200;
text-decoration: underline;
}
.name {
font-size: 14px;
font-size: 16px;
font-weight: 500;
color: var(--green);
}
.file {
font-size: 12px;
font-weight: 300;
font-size: 14px;
font-weight: 200;
color: var(--cyan);
}
.name,
.file {
opacity: 0.6;
opacity: 0.3;
}
`;

Expand Down Expand Up @@ -231,7 +235,7 @@ export function defineTreeElement() {
if (!withFile) {
return `
<div class="tag">
<span class="name">&lt;${name}&gt;</span>
<span class="name">&lt;/${name}&gt;</span>
</div>
`;
}
Expand Down
30 changes: 15 additions & 15 deletions packages/client/src/resolve/createVueResolver.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { isStr } from '@open-editor/shared';
import { isBol, isStr } from '@open-editor/shared';
import type { ResolveDebug } from './resolveDebug';
import type { ElementSourceMeta } from './resolveSource';
import { ensureFileName, isValidFileName } from './util';
Expand All @@ -19,14 +19,14 @@ export function createVueResolver<T = any>(options: VueResolverOptions<T>) {
deep: boolean,
) {
if (isVueSource(debug.originalElement)) {
resolveSourceFromVueSource(debug, tree, deep, options);
resolveVueSource(debug, tree, deep, options);
} else {
resolveSourceFromInstance(debug, tree, deep, options);
resolveVueInstance(debug.value, tree, deep, options);
}
};
}

function resolveSourceFromVueSource<T = any>(
function resolveVueSource<T = any>(
debug: ResolveDebug<T>,
tree: Partial<ElementSourceMeta>[],
deep: boolean,
Expand Down Expand Up @@ -96,16 +96,14 @@ function resolveVueSourceAnchor<T = any>(
return [];
}

function resolveSourceFromInstance<T = any>(
debug: ResolveDebug<T>,
function resolveVueInstance<T = any>(
instance: T,
tree: Partial<ElementSourceMeta>[],
deep: boolean,
options: VueResolverOptions,
) {
const { isValid, getNext, getFile, getName } = options;

let instance = debug.value;

while (isValid(instance)) {
const __file = getFile(instance);
if (isValidFileName(__file)) {
Expand All @@ -130,23 +128,25 @@ function parseVueSource(__source: string) {
};
}

let hasVueSource: boolean | null = null;
let cacheIsVueSource: boolean | undefined;
function isVueSource(element: HTMLElement) {
if (hasVueSource != null) return hasVueSource;
if (isBol(cacheIsVueSource)) {
return cacheIsVueSource;
}

while (element) {
if (getElementVueSource(element) != null) {
return (hasVueSource = true);
return (cacheIsVueSource = true);
}
element = element.parentElement!;
}

return (hasVueSource = false);
return (cacheIsVueSource = false);
}

const vueComponentNameRE = /([^/.]+)\.vue$/;
export function getNameByFile(file = '') {
return file.match(vueComponentNameRE)?.[1];
const nameRE = /([^/.]+)\.vue$/;
function getNameByFile(file = '') {
return file.match(nameRE)?.[1];
}

function getElementVueSource(element?: HTMLElement) {
Expand Down
3 changes: 1 addition & 2 deletions packages/client/src/resolve/util.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,9 @@ export function ensureFileName(fileName: string) {

export function isValidFileName(fileName?: string): fileName is string {
if (fileName) {
fileName = ensureFileName(fileName);
return (
!fileName.startsWith('/home/runner/') &&
!fileName.startsWith('/node_modules/')
!ensureFileName(fileName).startsWith('/node_modules/')
);
}
return false;
Expand Down
4 changes: 4 additions & 0 deletions packages/shared/src/type.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,3 +13,7 @@ export function isStr(value: any): value is string {
export function isNum(value: any): value is number {
return typeof value === 'number';
}

export function isBol(value: any): value is boolean {
return typeof value === 'boolean';
}

0 comments on commit bca1675

Please sign in to comment.