Skip to content

Commit

Permalink
#65 Переменные в стилях и стили для контролов
Browse files Browse the repository at this point in the history
  • Loading branch information
xaota committed Jul 15, 2017
1 parent 45c9ff6 commit 4558cf2
Show file tree
Hide file tree
Showing 3 changed files with 260 additions and 40 deletions.
59 changes: 19 additions & 40 deletions style.less
Original file line number Diff line number Diff line change
@@ -1,29 +1,6 @@
@charset "utf-8";

// Шрифт
@font-default: Tahoma; // Выберите шрифт для проекта

// Цвета
@color-black : #000;
@color-night : #444;
@color-silver: silver;
@color-white : #fff;
@color-prime : #F2FBFF;
@color-second: darken(@color-prime, 10%);
@color-paper : #fafafa;
@color-shadow: #ccc;

// Размеры
@height : 100vh;
@width : 100vw;
@sidebar: 320px;
@aside : @sidebar / 2;
@all : 100%;
@section: 50%;
@content: 55%;
@shadow-blur : 4px;
@shadow-offset: 2px;

@import "style/variables.less";
@import "/api/mixin.less";

* { .indent; }
Expand Down Expand Up @@ -73,7 +50,7 @@ aside { .color(@color-prime); }
main { .animate(.3s); }

/** @secton sidebar left */
ul.list.aside.tags, ul.list.aside.anekdots { margin-left: 10%; margin-top: 20px; list-style: none; }
ul.list.aside.tags, ul.list.aside.anekdots { margin-top: 20px; list-style: none; }
ul.list.aside.tags li, ul.list.aside.anekdots li {
&:hover { color: blue; .cursor; }
}
Expand All @@ -85,13 +62,13 @@ article#anekdot h2 { margin-bottom: 40px; }

/** @section panel right */
input#layer-editor-toggle ~ article form { display: block; overflow: hidden; width: 0; }
label[for="layer-editor-toggle"] { display: block; text-align: right; padding: 1em; }
label[for="layer-editor-toggle"] span { .cursor; margin-left: 1em;
&:hover { color: blue; }
}
label[for="layer-editor-toggle"] span.button { .inline; .color(@color-second, @color-black); .round(5px); padding: 5px 10px; .edge(@color-shadow);
&:hover { .edge(@color-second); .color(@color-paper, blue); }
}
// label[for="layer-editor-toggle"] { display: block; text-align: right; padding: 1em; }
// label[for="layer-editor-toggle"] span { .cursor; margin-left: 1em;
// &:hover { color: blue; }
// }
// label[for="layer-editor-toggle"] span.button { .inline; .color(@color-second, @color-black); .round(5px); padding: 5px 10px; .edge(@color-shadow);
// &:hover { .edge(@color-second); .color(@color-paper, blue); }
// }
input#layer-editor-toggle {
&:checked ~ article form { width: auto; .inline; vertical-align: top; .sizing; margin: 2%; }
}
Expand All @@ -100,20 +77,20 @@ input#layer-editor-toggle {
input#layer-editor-toggle:checked ~ article form#input-anekdot { width: 70%; }
input#layer-editor-toggle:checked ~ article form#input-tag { width: 20%; }

.form input[type="text"] { width: 100%; margin-top: 10px; margin-bottom: 10px; }
.form textarea { width: 100%; margin-top: 10px; margin-bottom: 10px; resize: none; }
.form input[type="submit"] { display:block; margin-right: 0; margin-left: auto; }
// .form input[type="text"] { width: 100%; margin-top: 10px; margin-bottom: 10px; }
// .form textarea { width: 100%; margin-top: 10px; margin-bottom: 10px; resize: none; }
// .form input[type="submit"] { display:block; margin-right: 0; margin-left: auto; }

div#next-anekdot { height: 100%; text-align: center;
&:before { content: ''; display: inline-block; height: 100%; vertical-align: middle; }
}
div#next-anekdot div { display: inline-block; vertical-align: middle; padding: 5px;
&:hover { cursor: pointer; .color(@color-paper, blue); }
}
div#next-anekdot div { display: inline-block; vertical-align: middle; .cursor; }

#panel > header > div.layer-controls { text-align: right; padding: .8em .4em; .sizing; }

/** @subsection layers */
article.layer { .animate(.3s); top: 0; right: 0; width: 0; height: 0; position: fixed; .color(@color-prime); box-sizing: border-box; }
#layer-editor-toggle:checked ~ #layer-editor { .size(55%, 100%); .shadow(-@shadow-offset, 0, @shadow-blur, @color-shadow); }
article.layer { .animate(.3s); top: 0; right: 0; width: 0; height: 0; position: fixed; .color(@color-prime); box-sizing: border-box; opacity: 0; }
#layer-editor-toggle:checked ~ #layer-editor { .size(55%, 100%); .shadow(-@shadow-offset, 0, @shadow-blur, @color-shadow); opacity: 1; }

/** @subsection splash */
#splash { display: none; background: fade(@color-second, 70%); .bind(0, 0, 0, 0, fixed);
Expand All @@ -124,3 +101,5 @@ input.splash { display: none;
&:checked ~ main { filter: blur(3px); }
}
#layer-editor-toggle:checked ~ #splash > label[for="layer-editor-toggle"] { display: block; }

@import "style/control.less";
208 changes: 208 additions & 0 deletions style/control.less
Original file line number Diff line number Diff line change
@@ -0,0 +1,208 @@
/** @section control - оформление контролов
* * button - кнопка
*
* * accent - действие
*/
@color-change-effect: 5%;
@ripple-effect-size: 120px;
@padding-size: .6em;
@ripple-effect-scale-small: 1;
@ripple-effect-scale-medium: 2;
@ripple-effect-scale-large: 3;
@ripple-effect-position-left: 50%;
@ripple-effect-position-top : 50%;
@ripple-effect-position-left: 50%;
@ripple-color-change-effect: 25%;

@keyframes ripple {
0% {
transform: scale(0);
}
20% {
transform: scale(1);
}
100% {
opacity: 0;
transform: scale(1);
}
}

.control {
background: none;
.edge;
.inline;
.sizing;
.select;
.font(1em);
.animate(.3s);
position: relative;
overflow: hidden;
padding: @padding-size (@padding-size * 2);
vertical-align: top;
.outline;
}

/** @section элементы */
.control.button {
text-align: center;
&:hover {
.cursor;
}
}

.control.button.accent {
.color(@color-accent, @color-white);
}
.control.button.fade {
background-color: fade(@color-black, 1.5 * @color-change-effect);
}

.control.input { // {element}.control.input > input + label
padding: 0;
border-bottom: 1px solid @color-accent;
& > input,
& > textarea {
.sizing;
.outline;
display: block;
width: 100%;
margin: 0;
padding: (@padding-size * 2) @padding-size;
background: none;
.edge;
.font(1em);
.animate(.2s);
&:focus, &:valid {
padding: (@padding-size * 2.5) (@padding-size) (@padding-size * 1.5);
}
}
// & > input:placeholder-shown, input:not([value]), input[value=""] {
// .edge(yellow);
// }
& > label {
position: absolute;
color: gray;
left: @padding-size;
pointer-events: none;
.animate(.2s);
top: @padding-size * 2.5;
.font(1em);
}
// & > input:not(:placeholder-shown) + label, & > input:not([value]) + label, & > input[value=""] + label, & > input:not(:valid) {

// }
& > input:focus + label, & > input:valid + label,
& > textarea:focus + label, & > textarea:valid + label {
font-size: .8em;
color: @color-accent;
// padding-left: @padding-size; // @TODO: rem
top: @padding-size / 3;
}

& > span:before {
content: '';
position: absolute;
display: block;
height: 0;
width: 0;
left: 50%;
bottom: 0;
.edge(@color-accent);
border-left: none;
border-right: none;
.animate(.2s);
}
& > input:focus ~ span:before,
& > textarea:focus ~ span:before {
left: 0;
width: 100%;
}

& > textarea { height: 200px; }
}

/** @subsection поведение */
.control:not(.input):before {
content: '';
display: block;
.bind(0,0,0,0,absolute);
.animate(.3s);
}
.control:not(.input):hover:before{
background: fade(@color-white, 4 * @color-change-effect);
}
.control.darken:not(.input):hover:before{
background: fade(@color-black, 1 * @color-change-effect);
}

.control:not(.input):after, .control.input > span.ripple:after {
content: '';
display: block;
position: absolute;
left: @ripple-effect-position-left;
top: @ripple-effect-position-top;
background-color: fade(@color-black, @ripple-color-change-effect);
border-radius: 100%;
opacity: .6;

transform: scale(0);
}
.control:not(.input).small:after {
@ripple-effect-radius: @ripple-effect-size * @ripple-effect-scale-small;
width: @ripple-effect-radius;
height: @ripple-effect-radius;
margin-left: -@ripple-effect-radius / 2;
margin-top: -@ripple-effect-radius / 2;
}
.control:not(.input).medium:after, .control.input > span.ripple:after {
@ripple-effect-radius: @ripple-effect-size * @ripple-effect-scale-medium;
width: @ripple-effect-radius;
height: @ripple-effect-radius;
margin-left: -@ripple-effect-radius / 2;
margin-top: -@ripple-effect-radius / 2;
}
.control:not(.input).large:after, .control.input.large > span.ripple:after {
@ripple-effect-radius: @ripple-effect-size * @ripple-effect-scale-large;
width: @ripple-effect-radius;
height: @ripple-effect-radius;
margin-left: -@ripple-effect-radius / 2;
margin-top: -@ripple-effect-radius / 2;
}
.control:not(.input).extra:after, .control.input.extra > span.ripple:after {
@ripple-effect-radius: @ripple-effect-size * @ripple-effect-scale-large * 2;
width: @ripple-effect-radius;
height: @ripple-effect-radius;
margin-left: -@ripple-effect-radius / 2;
margin-top: -@ripple-effect-radius / 2;
}

.control:not(.input):active:after, .control.input > :focus ~ span.ripple:after {
animation: ripple 1s ease-out;
}

/* fixes initial animation run, without user input, on page load.
*/
.control:not(.input):after {
visibility: hidden;
}

.control:not(.input):active:after {
visibility: visible;
}

// настройки
.control.edge {
.edge(@color-silver);
}
.control.block {
display: block;
}
.control.width {
width: 100%;
}
.control.left {
text-align: left;
}
.control.shadow {
.shadow(0, 0, @shadow-blur, @color-shadow);
}
33 changes: 33 additions & 0 deletions style/variables.less
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
// Шрифт
@font-default: Tahoma;

// Цвета
@color-black : #000;
@color-night : #444;
@color-silver: silver;
@color-white : #fff;
@color-prime : #F2FBFF;
@color-second: darken(@color-prime, 10%);
@color-paper : #fafafa;
@color-shadow: #ccc;
@color-accent: #03A9F4;

@darkPrimaryColor: #1976D2;
@primaryColor: #2196F3;
@lightPrimaryColor: #BBDEFB;
@textPrimaryColor: #FFFFFF;
@primaryTextColor: #212121;
@secondaryTextColor: #757575;
@dividerColor: #BDBDBD;
@ripple: #3f51b5;

// Размеры
@height : 100vh;
@width : 100vw;
@sidebar: 320px;
@aside : @sidebar / 2;
@all : 100%;
@section: 50%;
@content: 55%;
@shadow-blur : 4px;
@shadow-offset: 2px;

0 comments on commit 4558cf2

Please sign in to comment.