Skip to content

Commit 1f23bec

Browse files
authored
Merge pull request #11 from wireui/feature/buttons
feature/buttons
2 parents e97515c + fe3cb0a commit 1f23bec

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

59 files changed

+1897
-724
lines changed

.editorconfig

+1-1
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ trim_trailing_whitespace = true
1111
[*.md]
1212
trim_trailing_whitespace = false
1313

14-
[*.{yml,yaml}]
14+
[*.{yml,yaml,js}]
1515
indent_size = 2
1616

1717
[docker-compose.yml]

.eslintignore

+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
node_modules
2+
vendor
3+
public/dist

.eslintrc

+93
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,93 @@
1+
{
2+
"root": true,
3+
"plugins": ["import"],
4+
"extends": ["eslint:recommended"],
5+
"parserOptions": {
6+
"sourceType": "module",
7+
"allowImportExportEverywhere": true
8+
},
9+
"ignorePatterns": ["node_modules/*", "public/dist/*", "vendor/*"],
10+
"env": { "browser": true, "es6": true, "node": true },
11+
"rules": {
12+
"generator-star-spacing": "off",
13+
"arrow-parens": "off",
14+
"one-var": "off",
15+
"no-console": "warn",
16+
"no-debugger": "warn",
17+
18+
// Possible Errors
19+
"no-extra-parens": ["error", "all", { "returnAssign": false }],
20+
"import/first": "off",
21+
"import/named": "error",
22+
"import/namespace": "error",
23+
"import/default": "error",
24+
"import/export": "error",
25+
"import/extensions": "off",
26+
"import/no-unresolved": "off",
27+
"import/no-extraneous-dependencies": "off",
28+
"prefer-promise-reject-errors": "off",
29+
"template-curly-spacing": "off",
30+
31+
// Best Practices
32+
"eqeqeq": "error",
33+
"no-invalid-this": "error",
34+
"no-return-assign": ["error", "except-parens"],
35+
"no-unused-expressions": ["error", { "allowTernary": true }],
36+
"no-useless-concat": "error",
37+
"no-useless-return": "error",
38+
39+
// Variable
40+
"init-declarations": "error",
41+
"no-use-before-define": "error",
42+
43+
// Stylistic Issues
44+
"array-bracket-newline": [
45+
"error",
46+
{ "multiline": true, "minItems": null }
47+
],
48+
"array-bracket-spacing": "error",
49+
"brace-style": ["error", "1tbs", { "allowSingleLine": true }],
50+
"block-spacing": "error",
51+
"comma-dangle": "error",
52+
"comma-spacing": "error",
53+
"comma-style": "error",
54+
"computed-property-spacing": "error",
55+
"func-call-spacing": "error",
56+
"implicit-arrow-linebreak": ["error", "beside"],
57+
"indent": ["error", 2],
58+
"keyword-spacing": "error",
59+
"no-lonely-if": "error",
60+
"no-mixed-operators": "error",
61+
"no-multiple-empty-lines": ["error", { "max": 1, "maxEOF": 1 }],
62+
"no-tabs": "error",
63+
"no-unneeded-ternary": "error",
64+
"no-whitespace-before-property": "error",
65+
"nonblock-statement-body-position": "error",
66+
"object-property-newline": [
67+
"error",
68+
{ "allowAllPropertiesOnSameLine": true }
69+
],
70+
"quote-props": ["error", "consistent"],
71+
"quotes": ["error", "single"],
72+
"semi": ["error", "never"],
73+
"semi-spacing": "error",
74+
"space-before-blocks": "error",
75+
"space-before-function-paren": "error",
76+
"space-in-parens": "error",
77+
"space-infix-ops": "error",
78+
"space-unary-ops": "error",
79+
"padding-line-between-statements": [
80+
"error",
81+
{ "blankLine": "always", "prev": "*", "next": "return" }
82+
],
83+
84+
// ES6
85+
"arrow-spacing": "error",
86+
"no-confusing-arrow": "error",
87+
"no-duplicate-imports": "error",
88+
"no-var": "error",
89+
"object-shorthand": "error",
90+
"prefer-const": "error",
91+
"prefer-template": "error"
92+
}
93+
}

.php-cs-fixer.php

+17-17
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,17 @@
11
<?php
22

3-
use PhpCsFixer\Config;
4-
use PhpCsFixer\Finder;
3+
use PhpCsFixer\{Config, Finder};
54

65
$rules = [
7-
'align_multiline_comment' => false,
8-
'array_indentation' => true,
9-
'array_syntax' => ['syntax' => 'short'],
10-
'binary_operator_spaces' => [
11-
'default' => 'align_single_space_minimal',
12-
'operators' => ['=>' => 'align_single_space'],
6+
'@PSR2' => true,
7+
'group_import' => true,
8+
'align_multiline_comment' => false,
9+
'single_import_per_statement' => false,
10+
'array_indentation' => true,
11+
'array_syntax' => ['syntax' => 'short'],
12+
'binary_operator_spaces' => [
13+
'default' => 'align_single_space',
14+
'operators' => ['=>' => 'align_single_space_minimal'],
1315
],
1416
'blank_line_after_namespace' => true,
1517
'blank_line_after_opening_tag' => false,
@@ -20,8 +22,10 @@
2022
'position_after_control_structures' => 'same',
2123
'position_after_functions_and_oop_constructs' => 'next',
2224
],
23-
'cast_spaces' => ['space' => 'none'],
24-
'class_attributes_separation' => true,
25+
'lowercase_cast' => true,
26+
'no_short_bool_cast' => true,
27+
'cast_spaces' => ['space' => 'single'],
28+
'class_attributes_separation' => ['elements' => ['property' => 'one', 'method' => 'one']],
2529
'no_unused_imports' => true,
2630
'class_keyword_remove' => false,
2731
'combine_consecutive_issets' => false,
@@ -65,6 +69,7 @@
6569
'whitespace_after_comma_in_array' => true,
6670
'trim_array_spaces' => true,
6771
'unary_operator_spaces' => true,
72+
'php_unit_method_casing' => false,
6873
];
6974

7075
$finder = Finder::create();
@@ -73,13 +78,8 @@
7378
__DIR__ . '/app',
7479
]);
7580

76-
$config = new Config();
77-
78-
$config->setIndent(' ');
79-
80-
$config
81+
return (new Config())
82+
->setIndent(' ')
8183
->setRiskyAllowed(false)
8284
->setRules($rules)
8385
->setFinder($finder);
84-
85-
return $config;

README.md

+15-15
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# WireUI - Docs
22

3-
Page for [WireUI](https://github.com/wireui/wireui) documentation.
3+
Page for [WireUI](https://github.com/wireui/wireui) documentation.
44

55
Visit at: [https://livewire-wireui.com/](https://livewire-wireui.com/)
66

@@ -12,7 +12,7 @@ Thank you for your interest in contributing! 😊
1212

1313
Please follow the steps below to run this project locally:
1414

15-
### Get started 🚀
15+
### Get started 🚀
1616

1717
#### Requirements
1818

@@ -78,25 +78,26 @@ You are welcome to explore the code in `resources/views/livewire/` folder to vie
7878

7979
Code snippets should always be included using the `<x-code>` tag.
8080

81-
The mandatory attributes are `language`, for the code language and the `code`, for the code itself.
81+
The mandatory attributes are `language`, for the code language and the `contents`, for the code itself. Or use a `slot` instead of the `contents` attribute.
82+
8283

8384
For example:
8485

8586
```php
8687
//...
87-
<x-code language="bash" :code="<<<EOT
88-
php artisan vendor:publish --tag='wireui.config'
89-
php artisan vendor:publish --tag='wireui.resources'
90-
php artisan vendor:publish --tag='wireui.lang'
91-
EOT" />
88+
<x-code language="bash">
89+
php artisan vendor:publish --tag='wireui.config'
90+
php artisan vendor:publish --tag='wireui.resources'
91+
php artisan vendor:publish --tag='wireui.lang'
92+
</x-code>
9293
```
9394

9495
A copy button is loaded by default, to suppress the button, add the attribute: `copy="false"`.
9596

96-
Likewise, line numbers are displayed by default. To remove the numbers, add the attribute: `line-number="false`.
97+
Likewise, line numbers are displayed by default. To remove the numbers, add the attribute: `:line-numbers="false".
9798

9899
```php
99-
<x-code copy="false" line-numbers="false" language="shell" :code="Command exit with error error code xyz...." />
100+
<x-code no-copy :line-numbers="false" language="shell" :contents="Command exit with error error code xyz...." />
100101
```
101102

102103
<br/>
@@ -119,18 +120,17 @@ Run `npm install` to install all to install all dependencies.
119120

120121
#### Boxes
121122

122-
Sometimes it's crucial to highlight information such as a mandatory step or a compatibility issue. In these situations, situations, you should use the `<x-box attention>` tag, which will produce a yellow "attention" box.
123+
Sometimes it's crucial to highlight information such as a mandatory step or a compatibility issue. In these situations, situations, you should use the `<x-alerts.warning>` tag, which will produce a yellow "attention" box.
123124

124125
For example:
125126

126127
```php
127-
<x-box attention>If you are using FooJS 1.0, you must configure bar=null before update.</x-box>
128+
<x-alerts.warning>If you are using FooJS 1.0, you must configure bar=null before update.</x-alerts.warning>
128129
```
129-
130-
In addition, if you need to provide a friendly message, a tip, or extra information, you should use of the `<x-box info>` tag, which produces a blue info box.
130+
In addition, if you need to provide a friendly message, a tip, or extra information, you should use of the `<x-alerts.info>` tag, which produces a blue info box.
131131

132132
```php
133-
<x-box info>Read more about supported formats <a href="#formats">here</a>.</x-box>
133+
<x-alerts.info>Read more about supported formats <a href="#formats">here.</a></x-alerts.info>
134134
```
135135

136136
<br/>
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,63 @@
1+
<?php
2+
3+
namespace App\Http\Livewire\Docs\Buttons;
4+
5+
use Illuminate\Support\Facades\File;
6+
use Illuminate\Support\{Collection, Str};
7+
use Livewire\Component;
8+
use Symfony\Component\Finder\SplFileInfo;
9+
10+
/** @property-read string $buttonCode */
11+
class Playground extends Component
12+
{
13+
public ?string $label = 'Button';
14+
15+
public string $style = 'default';
16+
17+
public string $color = 'default';
18+
19+
public string $size = 'default';
20+
21+
public ?string $icon = null;
22+
23+
public ?string $rightIcon = null;
24+
25+
public function getButtonCodeProperty(): string
26+
{
27+
$attributes = collect([
28+
'label' => ['allow-default' => true, 'default' => 'Button', 'attr' => 'label'],
29+
'style' => ['allow-default' => false, 'default' => 'default', 'attr' => false],
30+
'color' => ['allow-default' => false, 'default' => 'default', 'attr' => false],
31+
'size' => ['allow-default' => false, 'default' => 'default', 'attr' => false],
32+
'icon' => ['allow-default' => false, 'default' => null, 'attr' => 'icon'],
33+
'rightIcon' => ['allow-default' => false, 'default' => null, 'attr' => 'right-icon'],
34+
])->filter(function (array $options, string $attribute) {
35+
if (!$this->{$attribute}) {
36+
return false;
37+
}
38+
39+
return $options['allow-default'] || $this->{$attribute} !== $options['default'];
40+
})->map(function (array $options, string $attribute) {
41+
return $options['attr']
42+
? "{$options['attr']}=\"{$this->{$attribute}}\""
43+
: $this->{$attribute};
44+
})->implode(' ');
45+
46+
return "<x-button {$attributes} />";
47+
}
48+
49+
public function getIconsProperty(): Collection
50+
{
51+
$path = base_path('vendor/wireui/wireui/resources/views/components/icons/outline');
52+
53+
return collect(File::files($path))
54+
->map(function (SplFileInfo $file) {
55+
return Str::before($file->getFilename(), '.blade.php');
56+
})->sortBy('name');
57+
}
58+
59+
public function render()
60+
{
61+
return view('livewire.docs.buttons.playground');
62+
}
63+
}

0 commit comments

Comments
 (0)