Skip to content

Commit

Permalink
Merge pull request #1908 from giovanniTramonto/universal-box-sizing-css
Browse files Browse the repository at this point in the history
set universal css box-sizing to border-box
  • Loading branch information
justvanrossum authored Jan 6, 2025
2 parents ad999d5 + 795c0d1 commit 1d343fb
Show file tree
Hide file tree
Showing 25 changed files with 30 additions and 47 deletions.
15 changes: 13 additions & 2 deletions src/fontra/client/core/html-utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ export class SimpleElement extends HTMLElement {
}

_attachStyles() {
this._appendStyleSheetLink("/css/shared.css");
if (this.constructor.styles) {
this._appendStyle(this.constructor.styles);
}
Expand All @@ -24,6 +25,10 @@ export class SimpleElement extends HTMLElement {
addStyleSheet(cssText, this.shadowRoot);
}

_appendStyleSheetLink(href) {
addStyleSheetLink(href, this.shadowRoot);
}

appendStyle(cssText) {
this._appendStyle(cssText);
}
Expand Down Expand Up @@ -147,8 +152,14 @@ export function addStyleSheet(cssText, element = null) {
if (!element) {
element = document.head;
}
const styleElement = style({}, [cssText]);
element.appendChild(styleElement);
element.appendChild(style({}, [cssText]));
}

export function addStyleSheetLink(href, element = null) {
if (!element) {
element = document.head;
}
element.appendChild(link({ href, rel: "stylesheet" }));
}

// Convenience shortcuts
Expand Down
2 changes: 0 additions & 2 deletions src/fontra/client/css/core.css
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,6 @@ body {
height: 10rem;
margin-top: -5rem;
margin-left: -5rem;
box-sizing: border-box;
border-radius: 50%;
border: 0.6rem solid #fff8;
border-top-color: #0005;
Expand All @@ -126,7 +125,6 @@ body {
input[type="text"],
input[type="number"],
input[type="password"] {
box-sizing: border-box;
background-color: var(--text-input-background-color);
color: var(--text-input-foreground-color);
border-radius: 0.25em;
Expand Down
5 changes: 5 additions & 0 deletions src/fontra/client/css/shared.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
*,
*::before,
*::after {
box-sizing: border-box;
}
1 change: 0 additions & 1 deletion src/fontra/client/web-components/glyph-search-field.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@ export class GlyphSearchField extends SimpleElement {
resize: none;
width: 100%;
height: 1.8em;
box-sizing: border-box;
padding: 0.2em 0.8em;
}
`;
Expand Down
1 change: 0 additions & 1 deletion src/fontra/client/web-components/glyph-search-list.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@ export class GlyphSearchList extends SimpleElement {
display: grid;
gap: 1em;
grid-template-rows: auto 1fr;
box-sizing: border-box;
overflow: hidden;
align-content: start;
}
Expand Down
1 change: 0 additions & 1 deletion src/fontra/client/web-components/modal-dialog.js
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,6 @@ export class ModalDialog extends SimpleElement {
height: 100%;
max-width: 100%;
max-height: 100%;
box-sizing: border-box;
}
dialog::backdrop {
Expand Down
4 changes: 0 additions & 4 deletions src/fontra/client/web-components/ui-accordion.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,15 +13,13 @@ export class Accordion extends UnlitElement {
text-wrap: wrap;
width: 100%;
height: 100%;
box-sizing: border-box;
}
.ui-accordion-item {
display: grid;
grid-template-rows: auto 1fr;
gap: 0.2em;
min-height: 0;
box-sizing: border-box;
}
.ui-accordion-item[hidden] {
Expand All @@ -35,7 +33,6 @@ export class Accordion extends UnlitElement {
align-items: center;
font-weight: bold;
cursor: pointer;
box-sizing: border-box;
}
.ui-accordion-item .open-close-icon {
Expand All @@ -54,7 +51,6 @@ export class Accordion extends UnlitElement {
.ui-accordion-item-content {
display: block;
box-sizing: border-box;
overflow: hidden;
}
`;
Expand Down
6 changes: 0 additions & 6 deletions src/fontra/client/web-components/ui-form.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@ export class Form extends SimpleElement {
display: grid;
align-items: center;
grid-template-columns: var(--label-column-width) auto;
box-sizing: border-box;
gap: 0.35rem 0.35rem;
margin: 0em;
padding: 0em;
Expand Down Expand Up @@ -64,7 +63,6 @@ export class Form extends SimpleElement {
}
input {
box-sizing: border-box;
background-color: var(--text-input-background-color);
color: var(--text-input-foreground-color);
border-radius: 0.25em;
Expand All @@ -75,10 +73,6 @@ export class Form extends SimpleElement {
font-size: 100%;
}
.ui-form-value {
box-sizing: border-box;
}
.ui-form-value input {
width: min(100%, 9.5em);
height: 1.6em;
Expand Down
6 changes: 1 addition & 5 deletions src/fontra/client/web-components/ui-list.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,14 +23,12 @@ export class UIList extends UnlitElement {
gap: 0.2em;
min-height: 0;
min-width: 0;
box-sizing: border-box;
}
.container {
overflow: auto;
height: 100%;
width: 100%;
box-sizing: border-box;
border: solid 1px var(--border-color);
background-color: var(--row-background-color);
}
Expand All @@ -54,15 +52,13 @@ export class UIList extends UnlitElement {
overflow: auto;
height: 100%;
width: 100%;
box-sizing: border-box;
scrollbar-width: none; /* hide scrollbar in FireFox */
}
.header {
display: flex;
width: min-content;
min-width: 100%;
box-sizing: border-box;
padding: 0.15em;
padding-left: 0.5em;
padding-right: 0.5em;
Expand All @@ -73,7 +69,6 @@ export class UIList extends UnlitElement {
display: flex;
width: min-content;
min-width: 100%;
box-sizing: border-box;
border-top: solid 1px var(--row-border-color);
color: var(--row-foreground-color);
background-color: var(--row-background-color);
Expand All @@ -92,6 +87,7 @@ export class UIList extends UnlitElement {
overflow: hidden;
text-overflow: ellipsis;
padding: 0 0.2em 0 0.1em;
box-sizing: content-box; /* FIXME: use border-box */
}
.list-cell.editing,
Expand Down
1 change: 1 addition & 0 deletions src/fontra/filesystem/landing.html
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
<head>
<meta charset="utf-8" />
<title>Fontra</title>
<link href="/css/shared.css" rel="stylesheet" />
<link href="/css/core.css" rel="stylesheet" />
<link href="/filesystem/landing.css" rel="stylesheet" />
<script type="module" src="/core/theme-settings.js"></script>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
<html lang="en">
<head>
<meta charset="utf-8" />
<link href="/css/shared.css" rel="stylesheet" />
<link href="/css/core.css" rel="stylesheet" />
<link href="/css/tooltip.css" rel="stylesheet" />
<title>Fontra Application Settings</title>
Expand All @@ -17,7 +18,6 @@
display: grid;
grid-template-columns: auto 1fr;
padding: 0em;
box-sizing: border-box;
gap: 0em;
width: 100vw;
height: 100vh;
Expand Down
1 change: 0 additions & 1 deletion src/fontra/views/applicationsettings/panel-shortcuts.js
Original file line number Diff line number Diff line change
Expand Up @@ -241,7 +241,6 @@ addStyleSheet(`
.fontra-ui-shortcuts-panel-input {
min-width: ${shortcutsPanelInputWidth};
text-align: center;
box-sizing: border-box;
background-color: var(--text-input-background-color);
color: var(--text-input-foreground-color);
border-radius: 0.25em;
Expand Down
11 changes: 1 addition & 10 deletions src/fontra/views/editor/editor.css
Original file line number Diff line number Diff line change
Expand Up @@ -189,13 +189,10 @@ body {
position: absolute;
display: grid;
grid-template-columns: 3.5em 1fr 3.5em;

box-sizing: border-box;
top: 0;
left: 0;
width: 100%;
height: 100%;

pointer-events: none;
}

Expand Down Expand Up @@ -242,19 +239,14 @@ body {
.sidebar-tab {
display: flex;
align-items: center;

z-index: 1; /* below the shadow box but above the tools*/

box-sizing: border-box;
width: var(--sidebar-tab-width);
height: 2.8em;
background-color: var(--ui-element-background-color);
box-shadow: 0px 3px 8px #0006;

cursor: pointer;
pointer-events: auto;
user-select: none;

animation-duration: 120ms;
animation-direction: alternate;
animation-timing-function: ease-out;
Expand Down Expand Up @@ -303,8 +295,6 @@ body {

.sidebar-content {
display: none;

box-sizing: border-box;
height: 100%;
width: 100%;
}
Expand Down Expand Up @@ -426,6 +416,7 @@ body {
padding: 0.1rem;
transition: 0.15s;
display: inline-grid;
box-sizing: content-box; /* FIXME: use border-box */
}

.tool-button:first-child,
Expand Down
1 change: 1 addition & 0 deletions src/fontra/views/editor/editor.html
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
<head>
<meta charset="utf-8" />
<title>Fontra</title>
<link href="/css/shared.css" rel="stylesheet" />
<link href="/css/core.css" rel="stylesheet" />
<link href="/editor/editor.css" rel="stylesheet" />
<link href="/css/tooltip.css" rel="stylesheet" />
Expand Down
6 changes: 2 additions & 4 deletions src/fontra/views/editor/panel-designspace-navigation.js
Original file line number Diff line number Diff line change
Expand Up @@ -175,8 +175,7 @@ export default class DesignspaceNavigationPanel extends Panel {
open: true,
content: html.div(
{
style:
"display: grid; grid-template-rows: 1fr auto auto; height: 100%; box-sizing: border-box;",
style: "display: grid; grid-template-rows: 1fr auto auto; height: 100%;",
},
[
html.createDomElement("ui-list", { id: "sources-list" }),
Expand All @@ -196,8 +195,7 @@ export default class DesignspaceNavigationPanel extends Panel {
open: true,
content: html.div(
{
style:
"display: grid; grid-template-rows: 1fr auto; height: 100%; box-sizing: border-box;",
style: "display: grid; grid-template-rows: 1fr auto; height: 100%;",
},
[
html.createDomElement("ui-list", { id: "layers-list" }),
Expand Down
2 changes: 1 addition & 1 deletion src/fontra/views/editor/panel-glyph-note.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ export default class GlyphNotePanel extends Panel {

static styles = `
.sidebar-glyph-note {
box-sizing: border-box;
height: 100%;
width: 100%;
display: flex;
Expand All @@ -30,6 +29,7 @@ export default class GlyphNotePanel extends Panel {
resize: none;
overflow-x: auto;
text-wrap: wrap;
box-sizing: content-box; /* FIXME: use border-box */
}
#glyph-note-textarea:disabled {
Expand Down
1 change: 0 additions & 1 deletion src/fontra/views/editor/panel-glyph-search.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ export default class GlyphSearchPanel extends Panel {

static styles = `
.glyph-search {
box-sizing: border-box;
height: 100%;
width: 100%;
display: grid;
Expand Down
1 change: 0 additions & 1 deletion src/fontra/views/editor/panel-reference-font.js
Original file line number Diff line number Diff line change
Expand Up @@ -194,7 +194,6 @@ export default class ReferenceFontPanel extends Panel {
padding: 1em;
gap: 1em;
height: 100%;
box-sizing: border-box;
white-space: normal;
align-content: start;
}
Expand Down
1 change: 0 additions & 1 deletion src/fontra/views/editor/panel-related-glyphs.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@ export default class RelatedGlyphPanel extends Panel {

static styles = `
.sidebar-glyph-relationships {
box-sizing: border-box;
height: 100%;
display: flex;
flex-direction: column;
Expand Down
1 change: 0 additions & 1 deletion src/fontra/views/editor/panel-selection-info.js
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,6 @@ export default class SelectionInfoPanel extends Panel {
display: flex;
flex-direction: column;
justify-content: space-between;
box-sizing: border-box;
height: 100%;
width: 100%;
white-space: normal;
Expand Down
3 changes: 2 additions & 1 deletion src/fontra/views/editor/panel-text-entry.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ export default class TextEntryPanel extends Panel {

static styles = `
.sidebar-text-entry {
box-sizing: border-box;
height: 100%;
width: 100%;
display: flex;
Expand All @@ -33,6 +32,7 @@ export default class TextEntryPanel extends Panel {
cursor: pointer;
user-select: none;
transition: 120ms;
box-sizing: content-box; /* FIXME: use border-box */
}
#text-align-menu > inline-svg:hover {
Expand All @@ -58,6 +58,7 @@ export default class TextEntryPanel extends Panel {
font-size: 1.1rem;
resize: none;
overflow-x: auto;
box-sizing: content-box;
}
`;

Expand Down
1 change: 0 additions & 1 deletion src/fontra/views/editor/panel-transformation.js
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,6 @@ export default class TransformationPanel extends Panel {
display: flex;
flex-direction: column;
justify-content: space-between;
box-sizing: border-box;
height: 100%;
width: 100%;
white-space: normal;
Expand Down
2 changes: 1 addition & 1 deletion src/fontra/views/fontinfo/fontinfo.html
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
<html lang="en">
<head>
<meta charset="utf-8" />
<link href="/css/shared.css" rel="stylesheet" />
<link href="/css/core.css" rel="stylesheet" />
<link href="/css/tooltip.css" rel="stylesheet" />
<title>Fontra Font Info</title>
Expand All @@ -15,7 +16,6 @@
display: grid;
grid-template-columns: auto 1fr;
padding: 0em;
box-sizing: border-box;
gap: 0em;
width: 100vw;
height: 100vh;
Expand Down
Loading

0 comments on commit 1d343fb

Please sign in to comment.