Skip to content

Commit

Permalink
fix: lint pint error
Browse files Browse the repository at this point in the history
  • Loading branch information
sensasi-delight committed Jun 26, 2024
1 parent ddbb0ce commit bdae1b7
Show file tree
Hide file tree
Showing 33 changed files with 170 additions and 138 deletions.
10 changes: 6 additions & 4 deletions src/Components/Alert.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,9 @@
class Alert extends Component
{
private string $cssColor;

private Severity $severity = Severity::SUCCESS;

private Variant $variant = Variant::STANDARD;

/**
Expand All @@ -23,9 +25,9 @@ class Alert extends Component
* @return void
*/
public function __construct(
string $severity = null,
string $color = null,
string $variant = null,
?string $severity = null,
?string $color = null,
?string $variant = null,

public ?string $icon = null,
public ?string $title = null,
Expand Down Expand Up @@ -63,7 +65,7 @@ public function attributesPreprocess(ComponentAttributeBag $attributes): Compone

if ($this->variant === Variant::OUTLINED) {
return $attributes->style([
"background-color: transparent",
'background-color: transparent',
"color: {$this->cssColor}",
"border: 1px solid color-mix(in srgb, {$this->cssColor} 70%, var(--mdc-theme-surface))",
])->class('mdc-typography--body1');
Expand Down
17 changes: 9 additions & 8 deletions src/Components/AppBar.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,16 +2,18 @@

namespace MaterialBlade\Components;


use Illuminate\View\Component;
use Illuminate\View\ComponentAttributeBag;
use MaterialBlade\Helper;

class AppBar extends Component
{
public ?string $title;

public ?string $variant;

public bool $isFixed;

public ?string $color;

/**
Expand Down Expand Up @@ -45,25 +47,24 @@ public function attributesPreprocess(ComponentAttributeBag $attributes)
{
if ($this->color) {
$attributes = $attributes->merge([
'style' => $attributes->prepends('--mdc-theme-primary: ' . Helper::getColor($this->color)),
'style' => $attributes->prepends('--mdc-theme-primary: '.Helper::getColor($this->color)),
]);
}

return $attributes->merge([
'data-mdc-auto-init' => 'MDCTopAppBar'
'data-mdc-auto-init' => 'MDCTopAppBar',
])->class([
'mdc-top-app-bar',
'mdc-top-app-bar--' . ($this->variant === 'short-collapsed' ? 'short mdc-top-app-bar--short-collapsed' : $this->variant) => $this->variant,
'mdc-top-app-bar--fixed' => $this->isFixed
'mdc-top-app-bar--'.($this->variant === 'short-collapsed' ? 'short mdc-top-app-bar--short-collapsed' : $this->variant) => $this->variant,
'mdc-top-app-bar--fixed' => $this->isFixed,
]);
}


public function startAttributesPreprocess(ComponentAttributeBag $attributes)
{
return $attributes->class([
'mdc-top-app-bar__section',
'mdc-top-app-bar__section--align-start'
'mdc-top-app-bar__section--align-start',
]);
}

Expand All @@ -73,7 +74,7 @@ public function endAttributesPreprocess(ComponentAttributeBag $attributes)

return $attributes->class([
'mdc-top-app-bar__section',
'mdc-top-app-bar__section--align-end'
'mdc-top-app-bar__section--align-end',
]);
}
}
9 changes: 5 additions & 4 deletions src/Components/Banner.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,16 +2,17 @@

namespace MaterialBlade\Components;


use Illuminate\View\Component;
use Illuminate\View\ComponentAttributeBag;
use MaterialBlade\Helper;

class Banner extends Component
{
public string $text;

public ?string $icon;

public ?string $actions;

public bool $isFixed;

/**
Expand Down Expand Up @@ -44,11 +45,11 @@ public function render()
public function attributesPreprocess(ComponentAttributeBag $attributes)
{
$attributes = $attributes->merge([
'role' => 'banner'
'role' => 'banner',
]);

return $attributes->class([
'mdc-banner mdc-banner--mobile-stacked mdc-banner--centered'
'mdc-banner mdc-banner--mobile-stacked mdc-banner--centered',
]);
}
}
15 changes: 11 additions & 4 deletions src/Components/Button.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,13 +10,20 @@
class Button extends Component
{
public string $color;

public bool $isFullwidth;

public bool $isRipple;

public bool $withWrapper;

public ?string $endIcon;

public ?string $label;

// public string $size;
public ?string $startIcon;

public ?string $variant;

/**
Expand All @@ -39,7 +46,7 @@ public function __construct(
$this->endIcon = $endIcon;
$this->isFullwidth = $fullwidth;
$this->label = $label;
$this->isRipple = !$disableRipple;
$this->isRipple = ! $disableRipple;
$this->startIcon = $startIcon;
$this->variant = $variant;
$this->withWrapper = $withWrapper;
Expand All @@ -58,7 +65,7 @@ public function render()

public function validateComponent(ComponentSlot $slot)
{
if (!$this->label && $slot->isEmpty()) {
if (! $this->label && $slot->isEmpty()) {
throw new \Exception('Please fill the "label" attribute or the component slot', 1);
}
}
Expand All @@ -67,14 +74,14 @@ public function attributesPreprocess(ComponentAttributeBag $attributes)
{
if ($this->color !== 'primary') {
$attributes = $attributes->merge([
'style' => $attributes->prepends('--mdc-theme-primary: ' . Helper::getColor($this->color))
'style' => $attributes->prepends('--mdc-theme-primary: '.Helper::getColor($this->color)),
]);
}

return $attributes->class([
'mdc-button',
'mdc-button--touch' => $this->withWrapper,
'mdc-button--' . ($this->variant) => $this->variant !== 'text' && in_array($this->variant, ['raised', 'unelevated', 'outlined']),
'mdc-button--'.($this->variant) => $this->variant !== 'text' && in_array($this->variant, ['raised', 'unelevated', 'outlined']),
'mdc-button--icon-leading' => $this->startIcon ? true : false,
'mdc-button--icon-trailing' => $this->endIcon ? true : false,
'fullwidth' => $this->isFullwidth,
Expand Down
7 changes: 3 additions & 4 deletions src/Components/Card.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,13 @@

namespace MaterialBlade\Components;


use Illuminate\View\Component;
use Illuminate\View\ComponentAttributeBag;
use MaterialBlade\Components\Card\Enums\Variant;

/**
* @property Variant $variant
*
*
* @see https://mui.com/material-ui/react-card/
* @see https://m2.material.io/components/cards
* @see https://material-components.github.io/material-components-web-catalog/#/component/elevation
Expand All @@ -27,7 +26,7 @@ class Card extends Component
* @return void
*/
public function __construct(
string $variant = null
?string $variant = null
) {
if ($variant) {
$this->variant = Variant::from($variant);
Expand All @@ -48,7 +47,7 @@ public function attributesPreprocess(ComponentAttributeBag $attributes)
{
return $attributes->class([
'mdc-card',
'mdc-card--outlined' => $this->variant === Variant::OUTLINED
'mdc-card--outlined' => $this->variant === Variant::OUTLINED,
]);
}
}
8 changes: 2 additions & 6 deletions src/Components/CardActions.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,21 +2,17 @@

namespace MaterialBlade\Components;


use Illuminate\View\Component;
use Illuminate\View\ComponentAttributeBag;

class CardActions extends Component
{

/**
* Create a new component instance.
*
* @return void
*/
public function __construct()
{
}
public function __construct() {}

/**
* Get the view / contents that represent the component.
Expand All @@ -31,7 +27,7 @@ public function render()
public function attributesPreprocess(ComponentAttributeBag $attributes)
{
return $attributes->class([
'mdc-card__actions'
'mdc-card__actions',
]);
}
}
7 changes: 2 additions & 5 deletions src/Components/CardContent.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@

namespace MaterialBlade\Components;


use Illuminate\View\Component;
use Illuminate\View\ComponentAttributeBag;

Expand All @@ -13,9 +12,7 @@ class CardContent extends Component
*
* @return void
*/
public function __construct()
{
}
public function __construct() {}

/**
* Get the view / contents that represent the component.
Expand All @@ -30,7 +27,7 @@ public function render()
public function attributesPreprocess(ComponentAttributeBag $attributes)
{
return $attributes->class([
'mdc-card__content'
'mdc-card__content',
]);
}
}
6 changes: 4 additions & 2 deletions src/Components/CardHeader.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,17 @@

namespace MaterialBlade\Components;


use Illuminate\View\Component;
use Illuminate\View\ComponentAttributeBag;

class CardHeader extends Component
{
public string $title;

public string $titleElement;

public string $subtitle;

public string $subtitleElement;

/**
Expand Down Expand Up @@ -43,7 +45,7 @@ public function render()
public function attributesPreprocess(ComponentAttributeBag $attributes)
{
return $attributes->class([
'mdc-card__header'
'mdc-card__header',
]);
}
}
7 changes: 3 additions & 4 deletions src/Components/CardMedia.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,13 @@

namespace MaterialBlade\Components;


use Illuminate\View\Component;
use Illuminate\View\ComponentAttributeBag;

class CardMedia extends Component
{

public string $src;

public string $variant;

/**
Expand All @@ -35,11 +34,11 @@ public function render()

public function attributesPreprocess(ComponentAttributeBag $attributes)
{
$attributes = $attributes->merge(['style' => $attributes->prepends('background-image: url(\'' . $this->src . '\');')]);
$attributes = $attributes->merge(['style' => $attributes->prepends('background-image: url(\''.$this->src.'\');')]);

return $attributes->class([
'mdc-card__media',
'mdc-card__media--' . $this->variant
'mdc-card__media--'.$this->variant,
]);
}
}
7 changes: 2 additions & 5 deletions src/Components/CardPrimaryAction.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@

namespace MaterialBlade\Components;


use Illuminate\View\Component;
use Illuminate\View\ComponentAttributeBag;

Expand All @@ -13,9 +12,7 @@ class CardPrimaryAction extends Component
*
* @return void
*/
public function __construct()
{
}
public function __construct() {}

/**
* Get the view / contents that represent the component.
Expand All @@ -32,7 +29,7 @@ public function attributesPreprocess(ComponentAttributeBag $attributes)
$attributes = $attributes->merge(['tabindex' => 0]);

return $attributes->class([
'mdc-card__primary-action'
'mdc-card__primary-action',
]);
}
}
5 changes: 3 additions & 2 deletions src/Components/Checkbox.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,15 @@

namespace MaterialBlade\Components;


use Illuminate\View\Component;
use Illuminate\View\ComponentAttributeBag;

class Checkbox extends Component
{
public ?string $color;

public ?string $label;

public bool $isIndeterminate;
// public bool $isDisabled;

Expand Down Expand Up @@ -47,7 +48,7 @@ public function attributesPreprocess(ComponentAttributeBag $attributes)
}

return $attributes->class([
'mdc-checkbox__native-control'
'mdc-checkbox__native-control',
]);
}
}
Loading

0 comments on commit bdae1b7

Please sign in to comment.