Skip to content

Commit a31f18b

Browse files
Merge pull request #14 from hananils/develop
Version 1.4.0
2 parents 7f35988 + b359f14 commit a31f18b

37 files changed

+4429
-3224
lines changed

.eslintrc.json

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
{
2+
"env": {
3+
"browser": true,
4+
"es2021": true
5+
},
6+
"extends": [
7+
"eslint:recommended",
8+
"plugin:vue/recommended",
9+
"prettier"
10+
],
11+
"parserOptions": {
12+
"ecmaVersion": 12,
13+
"sourceType": "module"
14+
}
15+
}

.gitignore

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
1-
/node_modules
2-
/.cache
1+
node_modules
2+
.DS_Store

.prettierrc

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,6 @@
11
{
2-
"printWidth": 80,
3-
"semi": true,
42
"singleQuote": true,
53
"trailingComma": "none",
6-
"bracketSpacing": true,
7-
"jsxBracketSameLine": true,
8-
"phpVersion": "7.3",
4+
"phpVersion": "7.4",
95
"trailingCommaPHP": false
106
}

composer.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,6 @@
1818
}
1919
},
2020
"require": {
21-
"getkirby/composer-installer": "^1.1"
21+
"getkirby/composer-installer": "^1.2"
2222
}
2323
}

composer.lock

Lines changed: 20 additions & 10 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

index.css

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

index.js

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

index.php

Lines changed: 10 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -2,25 +2,12 @@
22

33
@include_once __DIR__ . '/vendor/autoload.php';
44

5-
function getValue($value = null)
6-
{
7-
if (is_array($value)) {
8-
return $value[0];
9-
}
10-
11-
return $value;
12-
}
13-
145
Kirby::plugin('hananils/kirby-colors', [
156
'fields' => [
167
'colors' => [
178
'props' => [
189
'value' => function ($value = null) {
19-
if (is_array($value)) {
20-
return $value[0];
21-
}
22-
23-
return $value;
10+
return is_array($value) ? $value[0] : $value;
2411
},
2512
'help' => function ($help = null) {
2613
return $help;
@@ -30,28 +17,28 @@ function getValue($value = null)
3017
},
3118
'contrast' => function ($contrast = false) {
3219
return $contrast;
33-
},
20+
}
3421
],
3522
'save' => function ($value) {
3623
return $value;
37-
},
38-
],
24+
}
25+
]
3926
],
4027
'fieldMethods' => [
4128
'isHex' => function ($field) {
4229
$color = $field->toClass($field);
43-
return $color->isHex($value);
30+
return $color->toSpace() === 'hex';
4431
},
4532
'isRgb' => function ($field) {
4633
$color = $field->toClass($field);
47-
return $color->isRgb($value);
34+
return $color->toSpace() === 'rgb';
4835
},
4936
'isHsl' => function ($field) {
5037
$color = $field->toClass($field);
51-
return $color->isHsl($value);
38+
return $color->toSpace() === 'hsl';
5239
},
5340
'toClass' => function ($field) {
54-
$value = getValue($field->value);
41+
$value = is_array($field->value) ? $field->value[0] : $field->value;
5542
return new Hananils\Color($value);
5643
},
5744
'toColor' => function ($field, $space = null) {
@@ -111,6 +98,6 @@ function getValue($value = null)
11198
}
11299

113100
return array_shift($readable)['color']->toString($space);
114-
},
115-
],
101+
}
102+
]
116103
]);

lib/Color.php

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -127,7 +127,7 @@ public function setDefault()
127127
'h' => 0,
128128
's' => 0,
129129
'l' => 100,
130-
'a' => 100,
130+
'a' => 100
131131
]);
132132
}
133133

@@ -292,7 +292,7 @@ public function toValues($precision = 0)
292292
'h' => round($this->h, $precision),
293293
's' => round($this->s, $precision),
294294
'l' => round($this->l, $precision),
295-
'a' => round($this->a, $precision),
295+
'a' => round($this->a, $precision)
296296
];
297297
}
298298

@@ -304,7 +304,7 @@ public function toHex()
304304
'b' => $this->convertDecimalToHex($this->b),
305305
'a' => $this->convertDecimalToHex(
306306
$this->rebaseDecimalForHex($this->a)
307-
),
307+
)
308308
];
309309
}
310310

@@ -314,7 +314,7 @@ public function toRgb($precision = 0)
314314
'r' => round($this->r, $precision),
315315
'g' => round($this->g, $precision),
316316
'b' => round($this->b, $precision),
317-
'a' => $this->convertToFloat($this->a, $precision),
317+
'a' => $this->convertToFloat($this->a, $precision)
318318
];
319319
}
320320

@@ -324,7 +324,7 @@ public function toHsl($precision = 0)
324324
'h' => round($this->h, $precision),
325325
's' => round($this->s, $precision),
326326
'l' => round($this->l, $precision),
327-
'a' => $this->convertToFloat($this->a, $precision),
327+
'a' => $this->convertToFloat($this->a, $precision)
328328
];
329329
}
330330

lib/Readability.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ public function __construct(
3232
$this->combinations[] = [
3333
'color' => $color,
3434
'contrast' => $ratio,
35-
'accessibility' => $rating,
35+
'accessibility' => $rating
3636
];
3737
}
3838
}
@@ -118,7 +118,7 @@ public function toReport()
118118
{
119119
$report = [
120120
'color' => $this->color,
121-
'combinations' => $this->combinations,
121+
'combinations' => $this->combinations
122122
];
123123

124124
return $report;

0 commit comments

Comments
 (0)