ericlagarda/nova-text-card

为 Laravel Nova 定制的卡片,用于在卡片中显示文本,并具有一些优秀选项

v1.2 2020-06-03 16:41 UTC

This package is auto-updated.

Last update: 2024-08-29 05:00:25 UTC


README

为 Laravel Nova 定制的卡片,用于在卡片中显示文本,并具有一些优秀选项。

preview

安装

您可以通过 composer 将此包安装到使用 Nova 的 Laravel 应用中

composer require ericlagarda/nova-text-card

然后,在 NovaServiceProvidercards 方法或您的 ResourceTool 类中注册您的新链接。

public function cards()
{
    return [
        // ...
        // Examples from the preview image
 
        (new TextCard())
            ->forceFullWidth()
            ->heading('My custom awesome heading')
            ->text('Congue platea augue fames nullam morbi vehicula egestas lobortis lacus adipiscing eleifend'),

        (new TextCard())
            ->width('1/2')
            ->height(100)
            ->center(false)
            ->heading('Custom card no centered')
            ->text('Congue platea augue fames nullam morbi'),

        (new TextCard())
            ->width('1/2')
            ->height()
            ->text('<h4 class="font-light">This is a custom card with text and no heading. Height is set to auto.</h4>')
            ->textAsHtml(),

        (new TextCard())
            ->forceFullWidth()
            ->height(90)
            ->heading('<h1 class="text-3xl text-80 font-light">Just a heading text with a smile <svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24"><path class="fill-current" d="M12 2c5.514 0 10 4.486 10 10s-4.486 10-10 10-10-4.486-10-10 4.486-10 10-10zm0-2c-6.627 0-12 5.373-12 12s5.373 12 12 12 12-5.373 12-12-5.373-12-12-12zm6 14h-12c.331 1.465 2.827 4 6.001 4 3.134 0 5.666-2.521 5.999-4zm0-3.998l-.755.506s-.503-.948-1.746-.948c-1.207 0-1.745.948-1.745.948l-.754-.506c.281-.748 1.205-2.002 2.499-2.002 1.295 0 2.218 1.254 2.501 2.002zm-7 0l-.755.506s-.503-.948-1.746-.948c-1.207 0-1.745.948-1.745.948l-.754-.506c.281-.748 1.205-2.002 2.499-2.002 1.295 0 2.218 1.254 2.501 2.002z"/></svg></h1>')
            ->headingAsHtml(),
    ];
}

卡片选项

  • ->width('字符串'):卡片的宽度。
  • ->forceFullWidth():强制卡片全宽。修复 nova 卡片顺序问题。
  • ->height('字符串或数字'):卡片的高度。如果没有提供选项,高度将自动设置。默认为 nova 卡片高度。
  • ->center(boolean):如果您希望文本居中或不在。默认为 true。
  • ->heading('字符串或 HTML'):标题文本或自定义 HTML。默认为 false。不显示标题文本。
  • ->text('字符串或 HTML'):卡片文本或自定义 HTML。默认为 false。不显示文本。
  • ->headingAsHtml():如果您想将标题打印为 HTML。
  • ->textAsHtml():如果您想将文本打印为 HTML。