Knowledgebase

Building Reusable Blade Components Print

  • phplaravel, guide, howto, solution, zillionkinghost, hosting, support
  • 0

Shared interface pieces.

WHAT A COMPONENT IS

A reusable template fragment with its own parameters.

WHAT TO MAKE COMPONENTS OF

Buttons Form fields Cards and panels Alerts and messages Tables Modals

WHY

One definition, changed once, consistent everywhere.

WHAT TO DEFINE FOR EACH

What it accepts Sensible defaults Every state it supports

WHAT TO AVOID

Components with many parameters Components doing several unrelated things Duplicating a component because a variant was needed

WHAT TO DO INSTEAD OF DUPLICATING

Add a variant parameter.

WHAT TO KEEP OUT OF COMPONENTS

Queries Business logic

WHAT TO PASS IN

Prepared data.

WHERE TO ORGANISE THEM

A dedicated directory, grouped by kind.

WHAT TO DOCUMENT

What each is for, and when not to use it.

WHAT TO REVIEW

How many variants of the same thing exist.

Usually more than intended.


Was this answer helpful?
Back

Are you happy with your experience? Leave us a review on Trustpilot.


Trustpilot