Skip to content

Commit

Permalink
updated attrs, classes and removed assign_new not required
Browse files Browse the repository at this point in the history
  • Loading branch information
nhobes committed Oct 17, 2024
1 parent e2d93dc commit 156ec60
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 15 deletions.
19 changes: 10 additions & 9 deletions assets/default.css
Original file line number Diff line number Diff line change
Expand Up @@ -612,7 +612,12 @@
:not(.phx-no-feedback).pc-form-field-wrapper--error
.pc-switch
.pc-switch__fake-input {
@apply bg-danger-200 border-danger-500;
@apply bg-danger-200 border-danger-500 dark:bg-danger-600 dark:border-danger-800;
}
:not(.phx-no-feedback).pc-form-field-wrapper--error
.pc-radio-card
.pc-radio-card__fake-input {
@apply bg-danger-200 dark:bg-danger-800 border-danger-500;
}
:not(.phx-no-feedback).pc-form-field-wrapper--error .pc-label,
:not(.phx-no-feedback).pc-form-field-wrapper--error .pc-checkbox-label {
Expand Down Expand Up @@ -732,7 +737,7 @@
}

.pc-radio-card-group--row {
@apply flex-row;
@apply flex-col sm:flex-row;
}

.pc-radio-card-group--col {
Expand All @@ -748,19 +753,15 @@

/* Apply padding to .pc-radio-card__content */
.pc-radio-card--sm > .pc-radio-card__content {
@apply p-2;
@apply px-4 py-2;
}

.pc-radio-card--md > .pc-radio-card__content {
@apply p-4;
@apply px-8 py-4;
}

.pc-radio-card--lg > .pc-radio-card__content {
@apply p-6;
}

.pc-radio-card__icon {
@apply mb-2;
@apply px-12 py-6;
}

/* Adjust text size for labels */
Expand Down
13 changes: 7 additions & 6 deletions lib/petal_components/field.ex
Original file line number Diff line number Diff line change
Expand Up @@ -67,8 +67,8 @@ defmodule PetalComponents.Field do
attr :label_class, :any, default: nil, doc: "extra CSS for your label"
attr :selected, :any, default: nil, doc: "the selected value for select inputs"

attr :size, :string, default: nil, doc: "sm, md or lg - used by group-card"
attr :variant, :any, default: nil, doc: "outline, classic or surface - used by group-card"
attr :size, :string, default: "md", doc: "sm, md or lg - used by radio-card"
attr :variant, :any, default: "outline", doc: "outline, classic - used by radio-card"

attr :required, :boolean,
default: false,
Expand Down Expand Up @@ -303,9 +303,7 @@ defmodule PetalComponents.Field do
assigns =
assigns
|> assign_new(:checked, fn -> nil end)
|> assign_new(:size, fn -> "md" end)
|> assign_new(:class, fn -> "" end)
|> assign_new(:variant, fn -> "outline" end)
|> assign_new(:options, fn -> [] end)
|> assign_new(:group_layout, fn -> "row" end)
|> assign_new(:id_prefix, fn -> assigns.id || assigns.name || "radio_card" end)
Expand Down Expand Up @@ -335,15 +333,18 @@ defmodule PetalComponents.Field do
value={option[:value]}
disabled={option[:disabled]}
checked={
to_string(option[:value]) == to_string(@value) || to_string(option[:value]) == to_string(@checked)
to_string(option[:value]) == to_string(@value) ||
to_string(option[:value]) == to_string(@checked)
}
class="sr-only pc-radio-card__input"
{@rest}
/>
<div class="pc-radio-card__fake-input"></div>
<div class="pc-radio-card__content">
<div class="pc-radio-card__label"><%= option[:label] %></div>
<div :if={option[:description]} class="pc-radio-card__description"><%= option[:description] %></div>
<div :if={option[:description]} class="pc-radio-card__description">
<%= option[:description] %>
</div>
</div>
</label>
<% end %>
Expand Down

0 comments on commit 156ec60

Please sign in to comment.