View on GitLab

Typography

Larastrap provides a generic utility component called x-larastrap::t , able to be rendered as any preferred HTML tag type.

a simple span
<x-larastrap::t node="span">a simple span</x-larastrap::t>
<span id="basenode-eccbc87e4b5ce2fe28308fd9f2a7baf3" class="">a simple span</span>

Of course this is not meant to be directly used in templates - as it would be tedious and unconvenient to write so much code just to open and close a span - but is considered a base to define your own Custom Elements, so to define the typography style of your whole application and keep it consistent through the centralized configuration.

On this website, references to Larastrap components , parameters and examples of values are defined once in the global configuration as Custom Elements.

[
    'customs' => [
        'element' => [
            'extends' => 't',
            'params' => [
                'classes' => ['text-danger'],
                'node' => 'strong',
            ]
        ],

        'value' => [
            'extends' => 't',
            'params' => [
                'node' => 'code',
            ]
        ],

        'parameter' => [
            'extends' => 't',
            'params' => [
                'node' => 'strong',
            ]
        ]
    ]
]
<p>
    On this website, references to <x-larastrap::element>Larastrap components</x-larastrap::element>, <x-larastrap::parameter>parameters</x-larastrap::parameter> and <x-larastrap::value>examples of values</x-larastrap::value> are defined once in the global configuration as Custom Elements.
</p>
<p>
  On this website, references to <strong id="basenode-3cc57317e892542eb270979a5671e79c" class="text-danger">Larastrap components</strong> , <strong id="basenode-1679091c5a880faf6fb5e6087eb1b2dc" class="">parameters</strong> and <code id="basenode-8f14e45fceea167a5a36dedd4bea2543" class="">examples of values</code> are defined once in the global configuration as Custom Elements.
</p>

x-larastrap::t can be used to handle, among the other, classic Bootstrap Alerts and Badges: get a look to the page of Custom Elements Examples.

obj / name

x-larastrap::t is a Container, and an obj can be assigned (or inherited), but it also sports a few other parameters that permits you to display the value from a named attribute of the object (eventually: an Eloquent model) directly within the textual node

  • name - same as in Inputs, define the name of the attribute to access
  • prelabel / postlabel - same as in Buttons, permit to prepend or append an arbitrary text
kasandra.zboncak@example.com
@php
$user = App\Models\User::inRandomOrder()->first();
@endphp

<x-larastrap::t :obj="$user" name="email" />
<span id="basenode-36c8776a43c2724fd6311ef6bf08cd7e" class="">kasandra.zboncak@example.com</span>

In this case, also, it is possible to define your own Custom Elements to always display the same attribute with the same style, decorations, addictional graphics and more.

Eliezer Luettgen

ryan63@example.com

Edwina Hettinger

hermina.streich@example.net

Jules Wunsch

daniel.arlie@example.net

[
    'customs' => [
        'ctitle' => [
            'extends' => 't',
            'params' => [
                'node' => 'h5',
                'classes' => ['card-title'],
                'name' => 'name',
            ]
        ],
        'cmail' => [
            'extends' => 't',
            'params' => [
                'node' => 'p',
                'classes' => ['card-text'],
                'name' => 'email',
                'prelabel' => '<i class="bi bi-envelope"></i> '
            ]
        ],
    ]
]
@php
$users = App\Models\User::inRandomOrder()->take(3)->get();
@endphp

<div class="card-group">
    @foreach($users as $user)
        <x-larastrap::enclose :obj="$user">
            <div class="card">
                <div class="card-body">
                    <x-larastrap::ctitle />
                    <x-larastrap::cmail />
                </div>
            </div>
        </x-larastrap::enclose>
    @endforeach
</div>
<div class="card-group">
  <div class="card">
    <div class="card-body">
      <h5 id="basenode-bd61e4ea8b2fc1d9781779408ee34962" class="card-title">
        Eliezer Luettgen
      </h5>
      <p id="basenode-80eff27ed2b95d1c3e4f52fc48392925" class="card-text">
        ryan63@example.com
      </p>
    </div>
  </div>
  <div class="card">
    <div class="card-body">
      <h5 id="basenode-544a63f69bdf622dbc7c35aa9c79c3aa" class="card-title">
        Edwina Hettinger
      </h5>
      <p id="basenode-012f2e06bb20a26f08e26545781174c9" class="card-text">
        hermina.streich@example.net
      </p>
    </div>
  </div>
  <div class="card">
    <div class="card-body">
      <h5 id="basenode-fb10de3e8728afa88f36cbd95a07f61b" class="card-title">
        Jules Wunsch
      </h5>
      <p id="basenode-2cb76f2b09969f4c1e9a641e662c6365" class="card-text">
        daniel.arlie@example.net
      </p>
    </div>
  </div>
</div>