Skip to content
This repository has been archived by the owner on May 8, 2021. It is now read-only.

Commit

Permalink
Pure CSS gear icon
Browse files Browse the repository at this point in the history
  • Loading branch information
antsif-a committed Jul 23, 2020
1 parent d4ea000 commit b848331
Show file tree
Hide file tree
Showing 5 changed files with 151 additions and 60 deletions.
2 changes: 1 addition & 1 deletion src/window/components/console/console.css
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
.command-line {
padding-left: 5px;
padding-bottom: 5px;
min-width: calc(100% - 5px);
min-width: calc(100% - 3px);
position: fixed;
bottom: 0;
font-size: 20px;
Expand Down
42 changes: 42 additions & 0 deletions src/window/custom-elements/gear-icon/gear-icon.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
.gear-icon {
--icon-size: 0;

position: relative;
width: var(--icon-size);
height: var(--icon-size);
background: #fff;
border-radius: 50%;
}

.gear-icon-center {
position: absolute;
z-index: 10;
top: calc(var(--icon-size) / 4);
left: calc(var(--icon-size) / 4);
width: calc(var(--icon-size) / 2);
height: calc(var(--icon-size) / 2);
background: #000;
border-radius: 50%;
}

.gear-icon-tooth {
position: absolute;
z-index: 1;
top: calc(var(--icon-size) / -8);
left: calc(var(--icon-size) / 2.666666666666);
width: calc(var(--icon-size) / 4.44444444444);
height: calc(var(--icon-size) + var(--icon-size) / 4);
background: #fff;
}

.gear-icon-tooth:nth-child(2) {
transform: rotate(45deg);
}

.gear-icon-tooth:nth-child(3) {
transform: rotate(90deg);
}

.gear-icon-tooth:nth-child(4) {
transform: rotate(135deg);
}
43 changes: 43 additions & 0 deletions src/window/custom-elements/gear-icon/gear-icon.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
/**
* Custom gear HTML element.
* @example
* // Gear size is 100 px.
* <gear-icon size="20px"></gear-icon>
*/
class GearIcon extends HTMLElement {
/**
* Gear icon.
*/
constructor() {
super();

const shadow = this.attachShadow({ mode: 'closed' });

const wrapper = document.createElement('div');
wrapper.setAttribute('class', 'gear-icon');

const center = document.createElement('div');
center.setAttribute('class', 'gear-icon-center');

wrapper.appendChild(center);

for (let i = 0; i < 4; i++) {
const currentGearTooth = document.createElement('div');

currentGearTooth.setAttribute('class', 'gear-icon-tooth');
wrapper.appendChild(currentGearTooth);
}

const style = document.createElement('link');
style.setAttribute('rel', 'stylesheet');
style.setAttribute('href', './custom-elements/gear-icon/gear-icon.css');

shadow.appendChild(wrapper);
shadow.appendChild(style);

const size = this.getAttribute('size') || '0px';
wrapper.setAttribute('style', `--icon-size: ${size};`);
}
}

customElements.define('gear-icon', GearIcon);
121 changes: 62 additions & 59 deletions src/window/window.html
Original file line number Diff line number Diff line change
Expand Up @@ -6,85 +6,88 @@
<meta name="description" content="Mindustry server control panel.">
<meta name="author" content="Andrew &quot;Summet&quot; Antsiferov">
<link href="window.css" rel="stylesheet">
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/4.7.0/css/font-awesome.min.css">
<script src="window.js"></script>
<title>Server Console</title>
</head>
<body>
<div class="container">
<div class="titlebar">
<div class="titlebar-buttons">
<span class="titlebar-button" id="minimize"></span>
<span class="titlebar-button" id="maximize"></span>
<span class="titlebar-button" id="close"></span>
<div class="container">
<div class="titlebar">
<div class="titlebar-buttons">
<span class="titlebar-button" id="minimize"></span>
<span class="titlebar-button" id="maximize"></span>
<span class="titlebar-button" id="close"></span>
</div>
</div>
</div>

<div class="log" id="console-log"></div>
<div class="log" id="console-log"></div>

<div class="menu">
<span class="menu-title language-depend" translation="menu-players"></span>
<div class="menu-players menu-layout" id="console-players"></div>
<div class="menu">
<span class="menu-title language-depend" translation="menu-players"></span>
<div class="menu-players menu-layout" id="console-players"></div>

<span class="menu-title language-depend" translation="menu-statistics"></span>
<div class="menu-statistics menu-layout">
<div class="menu-meters">
<div class="menu-cpu menu-half-circle">
<div class="menu-cpu-overlay menu-half-circle-overlay">
<div class="menu-cpu-rotate menu-half-circle-rotate" id="cpu-rotate"></div>
<span class="menu-title language-depend" translation="menu-statistics"></span>
<div class="menu-statistics menu-layout">
<div class="menu-meters">
<div class="menu-cpu menu-half-circle">
<div class="menu-cpu-overlay menu-half-circle-overlay">
<div class="menu-cpu-rotate menu-half-circle-rotate" id="cpu-rotate"></div>
</div>
<span id="cpu-value">0%<br>CPU</span>
</div>
<br>
<div class="menu-ram menu-half-circle">
<div class="menu-ram-overlay menu-half-circle-overlay">
<div class="menu-ram-rotate menu-half-circle-rotate" id="ram-rotate"></div>
</div>
<span id="ram-value">0%<br>RAM</span>
</div>
<span id="cpu-value">0%<br>CPU</span>
</div>
<br>
<div class="menu-ram menu-half-circle">
<div class="menu-ram-overlay menu-half-circle-overlay">
<div class="menu-ram-rotate menu-half-circle-rotate" id="ram-rotate"></div>

<div class="menu-info">
<div class="menu-info-card">
<span class="language-depend" translation="menu-players"></span>
:&nbsp;
<span id="menu-info-players-value">0</span>
</div>
<div class="menu-info-card">
<span class="language-depend" translation="menu-maps"></span>
:&nbsp;
<span id="menu-info-maps-value">0</span>
</div>
<div class="menu-info-card">
<span class="language-depend" translation="menu-mods"></span>
:&nbsp;
<span id="menu-info-mods-value">0</span>
</div>
<div class="menu-info-card">
<span class="language-depend" translation="menu-plugins"></span>
:&nbsp;
<span id="menu-info-plugins-value">0</span>
</div>
<span id="ram-value">0%<br>RAM</span>
</div>
</div>

<div class="menu-info">
<div class="menu-info-card">
<span class="language-depend" translation="menu-players"></span>
:&nbsp;
<span id="menu-info-players-value">0</span>
<div class="menu-buttons">
<div class="menu-buttons-up">
<button class="menu-button language-depend" id="menu-host" translation="menu-host"></button>
<button class="menu-button language-depend" id="menu-stop" translation="menu-stop"></button>
<button class="menu-button language-depend" id="menu-break" translation="menu-break"></button>
</div>
<div class="menu-info-card">
<span class="language-depend" translation="menu-maps"></span>
:&nbsp;
<span id="menu-info-maps-value">0</span>
</div>
<div class="menu-info-card">
<span class="language-depend" translation="menu-mods"></span>
:&nbsp;
<span id="menu-info-mods-value">0</span>
</div>
<div class="menu-info-card">
<span class="language-depend" translation="menu-plugins"></span>
:&nbsp;
<span id="menu-info-plugins-value">0</span>
<div class="menu-buttons-down">
<button
class="menu-button language-depend"
id="menu-server-folder"
translation="menu-server-folder">
</button>
</div>
</div>
</div>

<div class="menu-buttons">
<div class="menu-buttons-up">
<button class="menu-button language-depend" id="menu-host" translation="menu-host"></button>
<button class="menu-button language-depend" id="menu-stop" translation="menu-stop"></button>
<button class="menu-button language-depend" id="menu-break" translation="menu-break"></button>
</div>
<div class="menu-buttons-down">
<button class="menu-button language-depend" id="menu-server-folder" translation="menu-server-folder"></button>
</div>
<div class="command-line">
<label for="console-input">></label>
<input autofocus class="command-line-input" id="console-input" type="text">
<gear-icon size="20px" class="console-settings"></gear-icon>
</div>
</div>

<div class="command-line">
<label for="console-input">></label>
<input autofocus class="command-line-input" id="console-input" type="text">
<span class="fa fa-gear console-settings"></span>
</div>
</div>
</body>
</html>
3 changes: 3 additions & 0 deletions src/window/window.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,9 @@ const Console = require('./components/console/console');

// Main point to the renderer process.
document.addEventListener('DOMContentLoaded', () => {
// Load custom HTML elements.
require('./custom-elements/gear-icon/gear-icon');

/**
* Class for operating with renderer side.
* @type {Console}
Expand Down

0 comments on commit b848331

Please sign in to comment.