-
Notifications
You must be signed in to change notification settings - Fork 0
Add titles to cards #46
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
9 commits
Select commit
Hold shift + click to select a range
269e0d3
Use template file for cards
koppen 6c3422a
Add title argument to card
koppen 3918351
Render the title as a component slot
koppen 965ecbc
Match Card title API to the other components
koppen fa59846
Pass options to Card Title component
koppen c9dbc5e
Always return a Hash
koppen e46397e
Improve documentation
koppen 4cc0ac4
Fix render slot
koppen c0277e1
Add Card to README
koppen File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,6 @@ | ||
| <%= content_tag(:div, card_options) do %> | ||
| <%= title %> | ||
| <% if content.present? %> | ||
| <div class="font-normal text-gray-700 dark:text-gray-400"><%= content %></div> | ||
| <% end %> | ||
| <% end %> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,37 @@ | ||
| # frozen_string_literal: true | ||
|
|
||
| module Flowbite | ||
| class Card | ||
| # Renders the title of a card element. | ||
| class Title < ViewComponent::Base | ||
| class << self | ||
| def classes(state: :default, style: :default) | ||
| style = styles.fetch(style) | ||
| style.fetch(state) | ||
| end | ||
|
|
||
| # rubocop:disable Layout/LineLength | ||
| def styles | ||
| { | ||
| default: Flowbite::Style.new( | ||
| default: ["mb-2", "text-2xl", "font-bold", "tracking-tight", "text-gray-900", "dark:text-white"] | ||
| ) | ||
| }.freeze | ||
| end | ||
| # rubocop:enable Layout/LineLength | ||
| end | ||
|
|
||
| def call | ||
| title_options = { | ||
| class: self.class.classes | ||
| }.merge(@options) | ||
|
|
||
| content_tag(:h5, content, **title_options) | ||
| end | ||
|
|
||
| def initialize(**options) | ||
| @options = options || {} | ||
koppen marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| end | ||
| end | ||
| end | ||
| end | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,8 +1,25 @@ | ||
| # frozen_string_literal: true | ||
|
|
||
| class CardPreview < Lookbook::Preview | ||
| # @!group Default card | ||
|
|
||
| # Use the following simple card component with a title and description. | ||
| def default | ||
| render(Flowbite::Card.new) { "Use the following simple card component with a title and description." } | ||
| end | ||
|
|
||
| def with_title_argument | ||
| render(Flowbite::Card.new(title: {content: "Card Title"})) do | ||
| "This card includes a title with the default styling." | ||
| end | ||
| end | ||
|
|
||
| def with_title_slot | ||
| render(Flowbite::Card.new) do |component| | ||
| component.with_title { "<h1 class=\"text-3xl\">This title replaces the entire title element</h1>".html_safe } | ||
| "Use the title slot to control all aspects of the title element" | ||
| end | ||
| end | ||
|
|
||
| # @!endgroup | ||
| end |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.