diff --git a/app/View/Components/Button.php b/app/View/Components/Button.php new file mode 100644 index 0000000..0d8cfae --- /dev/null +++ b/app/View/Components/Button.php @@ -0,0 +1,62 @@ +variant) { + self::VARIANT_SECONDARY => [ + 'base' => 'bg-secondary text-text', + 'hover' => 'hover:bg-secondary-dark', + 'disabled' => 'disabled:bg-secondary', + ], + self::VARIANT_OUTLINE => [ + 'base' => 'bg-surface border border-primary text-primary', + 'hover' => 'hover:bg-primary hover:text-text-inverted', + 'disabled' => 'disabled:bg-surface disabled:text-primary', + ], + default => [ + 'base' => 'bg-primary text-text-inverted', + 'hover' => 'hover:bg-primary-dark', + 'disabled' => 'disabled:bg-primary' + ] + }; + + $baseDisabled = 'disabled:cursor-not-allowed disabled:opacity-60'; + + return trim( + $base . ' ' . + $classes['base'] . ' ' . + $classes['hover'] . ' ' . + $baseDisabled . ' ' . + $classes['disabled'] + ); + } + + /** + * Get the view / contents that represent the component. + */ + public function render(): View + { + return view('components.button'); + } +} diff --git a/app/View/Components/Card.php b/app/View/Components/Card.php new file mode 100644 index 0000000..48fa444 --- /dev/null +++ b/app/View/Components/Card.php @@ -0,0 +1,21 @@ +merge(['class' => $classes()]) + ->merge(['disabled' => $disabled]) + }} +> + {{ $slot }} + diff --git a/resources/views/components/card.blade.php b/resources/views/components/card.blade.php new file mode 100644 index 0000000..66e8f20 --- /dev/null +++ b/resources/views/components/card.blade.php @@ -0,0 +1,10 @@ +
+ @if(!empty($header)) +
+

{{ $header }}

+
+ @endif +
+ {{ $slot }} +
+
\ No newline at end of file diff --git a/resources/views/storybook/index.blade.php b/resources/views/storybook/index.blade.php new file mode 100644 index 0000000..1b376d1 --- /dev/null +++ b/resources/views/storybook/index.blade.php @@ -0,0 +1,19 @@ + + + + + Storybook + + @vite(['resources/css/app.css', 'resources/js/app.js']) + + + +

Storybook

+ + @include('storybook.sections.colours') + @include('storybook.sections.buttons') + @include('storybook.sections.cards') + @include('storybook.sections.typography') + + + diff --git a/resources/views/storybook/sections/buttons.blade.php b/resources/views/storybook/sections/buttons.blade.php new file mode 100644 index 0000000..66a004e --- /dev/null +++ b/resources/views/storybook/sections/buttons.blade.php @@ -0,0 +1,30 @@ +
+

Buttons

+

Enabled

+ +
+ Default + + Primary + + + Secondary + + + Outline +
+ +

Disabled

+ +
+ Default + + Primary + + + Secondary + + + Outline +
+
diff --git a/resources/views/storybook/sections/cards.blade.php b/resources/views/storybook/sections/cards.blade.php new file mode 100644 index 0000000..6b428e8 --- /dev/null +++ b/resources/views/storybook/sections/cards.blade.php @@ -0,0 +1,13 @@ +
+

Cards

+

With Header

+ + +

This is a card component with header.

+
+ +

Without Header

+ +

This is a card component without header.

+
+
diff --git a/resources/views/storybook/sections/colours.blade.php b/resources/views/storybook/sections/colours.blade.php new file mode 100644 index 0000000..6e376c9 --- /dev/null +++ b/resources/views/storybook/sections/colours.blade.php @@ -0,0 +1,9 @@ +
+

Colors

+ +
+
Primary
+
Secondary
+
Surface
+
+
diff --git a/resources/views/storybook/sections/typography.blade.php b/resources/views/storybook/sections/typography.blade.php new file mode 100644 index 0000000..0a267e7 --- /dev/null +++ b/resources/views/storybook/sections/typography.blade.php @@ -0,0 +1,7 @@ +
+

Typography

+ +

Default text

+

Muted text

+

Primary text

+
diff --git a/routes/web.php b/routes/web.php index 86a06c5..16e9d0c 100644 --- a/routes/web.php +++ b/routes/web.php @@ -5,3 +5,7 @@ use Illuminate\Support\Facades\Route; Route::get('/', function () { return view('welcome'); }); + +Route::get('/storybook', function () { + return view('storybook.index'); +})->name('storybook'); diff --git a/tests/Feature/Component/ButtonTest.php b/tests/Feature/Component/ButtonTest.php new file mode 100644 index 0000000..1366139 --- /dev/null +++ b/tests/Feature/Component/ButtonTest.php @@ -0,0 +1,43 @@ +blade('Click!'); + + $view->assertSeeHtml('