Changelog
0.11.0
Pagination component
- Added attribute
button_attrsto render buttons withphx-attributes. This is useful on pages where handling of url parameters is too complex - for example when using search within a nested component. - Changed styling from inline-block to inline-flex to prevent spaces in labels from creating redundant whitespace.
Other changes
- Added possible attributes to slots to prevent "undefined attribute" warnings.
- Updated upstream dependency
@primer/view-componentsto0.40.0. - Updated LiveView JS dependency to
1.0.0.
0.10.0
LiveView 1.0
- Support for Phoenix.LiveView 1.0.
See Installation for using PrimerLive with Phoenix.LiveView 0.20.
Other changes
- Improve disabled Toggle switch styles.
- Updated upstream dependency
@primer/cssto21.5.1. - Updated upstream dependency
@primer/view-componentsto0.36.1.
0.9.1
Improvements for theme color CSS variables:
- Fix for a regression bug (introduced in version 0.9.0) that removed color styles unless components were wrapped in a theme wrapper. The light theme CSS variables are now set as the default.
- When using the
@scoperule, color CSS variables now work inside the scope.
0.9.0
Changes
- Text input: Set disabled color on read-only field with inset style.
- Checkbox group and Radio group: Show required marker in legend.
- Action menu and Select menu: Added attribute
offset_xto define the absolute offset for the menu on the horizontal axis. - Header: added attributes
variant="base"to create a light colored header, andis_compactfor a smaller vertical height. - Updated upstream Primer Design System libraries. This update includes a number of changes to modified CSS Custom Properties.
- Updated upstream dependency
@primer/cssto21.5.0. - Added
@primer/view-componentsversion0.34.0. This is the Rails version of Primer Design, which is the most developed so far. - Updated Octicon icons to version
v19.12.0.
- Updated upstream dependency
- Added support for right-to-left languages.
- Added support for
@scope, allowing PrimerLive to be used alongside other CSS libraries. See usage instructions in Installation. - Added documentation Styling. This contains notes about styling with custom CSS and pre-made classes, reusing styled components and support for right-to-left languages.
Depreciations
Standalone form_control as wrapper is soft-deprecated.
The use of form_control as wrapper component around a form input component was causing compatibility issues with displaying validation messages. Since input components should be able to display a validation message even when not wrapped inside a form_control, it became difficult to distinguish between a validation messages originating from the form_control and one originating from the nested input.
With the introduction of checkbox_group and radio_group in version 0.5, there has been less need for a standalone form control wrapper.
Overall, moving form_control to the background and using it only as an internal component resolves a range of problems.
See "Updating to 0.9" below.
Removals
form_groupwas soft-deprecated in 0.5.0 and has been removed, along with component attributesform_groupandis_form_group.
Bug fixes
- Checkbox group and Radio group: Restored display of validation message.
- Textarea: Set correct success color when displaying success feedback.
Updating to 0.9
form_control
There have 2 ways to create a form control: as a wrapper, and as an input attribute. If you've been using form_control as wrapper around inputs, change:
<.form :let={f} for={@changeset}>
<.form_control form={f} field={:first_name} for="first-name">
<.text_input form={f} field={:first_name} id="first-name" />
</.form_control>
</.form>to
<.form :let={f} for={@changeset}>
<.text_input form={f} field={:first_name} id="first-name" is_form_control />
</.form>CSS Custom Properties (Variables)
If you are using CSS Custom Properties from the Primer Design System, these may need to be updated. Verify the current available options in primer-live.css.
0.8.0
Refactoring of dialogs, drawers, and menus
This refactoring builds on the Phoenix.LiveView.JS API - taking example from CoreComponent's modal component. These changes reduce reliance on additional JavaScript, improve alignment with standard practice, and include accessibility improvements.
Overview:
See component documentation for further details:
Additions
- Dialogs, drawers and menus can now be shown conditionally, for example on a
live_actionroute:
<.dialog
:if={@live_action == :create}
is_show
id="new-post-dialog"
on_cancel={JS.patch(~p"/posts")}
>
...
</.dialog>- Added
PrimerLive.StatefulConditionComponent. - Dialog state is now preserved on form updates.
- Added attribute
focus_after_closing_selector, mirroring the (renamed)focus_after_opening_selector. - Added attribute
on_cancel. - Added attribute
transition_duration. - Added attribute
show_stateto persist dialogs, drawers and menus across different LiveViews. - Added
backdrop_tintwith values "dark" (default) and "light". The latter (combined withbackdrop_strength="strong") (see below) creates a backdrop that is similar to the CoreComponent's modal. - Added focus trap.
Changes and removals
See for update instructions: "Updating to 0.8" below.
- Prompt functions
showandhideare replaced withopen_dialog,close_dialogandcancel_dialog. - Replaced attribute
prompt_optionsfor status callbacks withstatus_callback_selectorthat sends status events to the component, so that state changes can be used in Elixir code. - Removed attribute
phx_click_touchin favor of usingstatus_callback_selector, because closing can be initiated in several ways, not only through backdrop clicks, and we can't assume that the event handler always hosts the dialog/drawer as well. - Renamed attribute
focus_firsttofocus_after_opening_selector. Focus on the first interactive element is now default; withfocus_after_opening_selectora specific element can be appointed. - Removed attrs
formandfieldfrom all prompt components. - Added separate
z-indexsettings for menus, so that the menu panel (and optional backdrop) are closer to the page, allowing them to be covered by other elements such as top bars. Using az-indexof100for a top bar ensures that it sits in between menus and dialogs/drawers. - Replaced backdrop attributes
is_dark_backdrop,is_medium_backdropandis_light_backdropwithbackdrop_strengthand values"strong","medium"and"light". - Menus and dialogs can now be closed with Escape by default.
Other changes
Box with streams
The box component now supports streams:
<.box stream={@streams.clients} id="clients">
<:row :let={{_dom_id, data}}>
<%= data.name %>
</:row>
</.box>This includes a breaking change: let is now reserved for stream data, so the callback data no longer contains classes.
Event attributes for slots
Slots now accept these "all-purpose" event attributes:
phx-clickphx-targetphx-value-item
Components:
box: slotrowbreadcrumb: slotitemdialog: slotrowdropdown: slotitemfilter_list: slotitemheader: slotitemmenu: slotitemselect_menu: slotitemside_nav: slotitemsubnav_links: slotitemtabnav: slotitemtruncate: slotitemunderline_nav: slotitem
Example with tabnav:
<:item
:for={%{label: label, id: tab_id} <- @tabs}
is_selected={id == @selected_tab}
phx-click="set_tab"
phx-value-item={tab_id}
>
...
def handle_event(
"set_tab", %{"item" => tab_id}, socket) do
...Fieldset wrapper for checkbox_group and radio_group
The form group created by checkbox_group and radio_group is now automatically wrapped in a fieldset. The label attribute generates a legend element.
Updated Octicons
This update to version 19.11.0 includes around 50 additions. See primer-live.org/octicon for a visual list.
Accessibility
- Added ARIA tags
aria-haspopupandaria-owns. - DOM ids are reformatted to a DOM-safe ID string.
Updating to 0.8
Replace
Promp.showandPrompt.hide:For example:
onclick="Prompt.show('#my-dialog')" onclick="Prompt.hide('#my-dialog')"Becomes:
phx-click={open_dialog("my-dialog")} phx-click={close_dialog("my-dialog")}
Replace backdrop darkness attributes:
is_dark_backdropbecomesbackdrop_strength="strong"is_medium_backdropbecomesbackdrop_strength="medium"is_light_backdropbecomesbackdrop_strength="light"
Attribute
is_escapablecan be removed because this is now the default. If the component should not be removed using Escape, useis_escapable={false}.
Less used attributes
Form state: the previous method to preserve state, using "a fictitious and unique field name" can be removed.
- Remove
formandfieldfrom menu and dialog component attributes.
- Remove
Because
focus_first(without a selector) is now the default, nothing needs to be changed when using this attribute.- If in existing code a selector value is used, rename the attribute to
focus_after_opening_selector.
- If in existing code a selector value is used, rename the attribute to
Replace
prompt_optionsandphx_click_touchwithstatus_callback_selector. There's no simple way to replaceprompt_options, because passing JavaScript functions is no longer supported. A solution could be very similar to the previousphx_click_touchmethod. See Status callbacks for an example.If you use
checkbox_grouporradio_groupinside afieldset, remove the fieldset as it is now redundant.If you are using
boxwith a:letcallback:Previous:
<:row :let={classes}> <.link href="/" class={classes.link}>Home</.link> </:row>Becomes:
<:row> <.link href="/" class="Box-row-link">Home</.link> </:row>
0.7.2
Changes
- Fixes support for Ash 3. Thanks @ademenev!
- Internal improvements
0.7.1
Changes
- Added dialog attr
is_show_on_mount. - Downgraded dependency @primer/css to 21.0.7 due to regressions.
0.7.0
Updated dependencies:
phoenix_ectoto4.5phoenix_htmlto4.1- Added
phoenix_html_helpers
- Added
phoenix_live_viewto0.20@primer/cssto21.2.2
Removed support for Ash Framework due to incompatible dependencies.
0.6.4
Reverted dependency @primer/css to 21.0.9 because of an excessively increased file size in later versions.
0.6.3
Changes
- Class attrs now support class notation from Surface. Thanks @tunchamroeun!
- Component
pagination: added class entry for "current_page" which now can receive a custom class.
0.6.2
Bug fixes
- Pagination: fixes the calculation when a gap between page numbers should be shown.
Other changes
- Pagination: added
roleand improved ARIA labels.
0.6.1
Bug fixes:
- Fixes reading the required state of input fields.
0.6.0
Added support for forms created with Ash Framework. See test/frameworks/ash/form_test.exs for an example.
0.5.4
Fixed a bug where the required marker would always be displayed, regardless of the field's required state.
0.5.3
Downgraded phoenix_live_view version to 0.19; both 0.19 and 0.20 should be compatible.
0.5.2
Added JS and CSS exports for Prompt functionality only. This is useful when you want to use menu/dialog/drawer behavior without Primer Design CSS. See the installation documentation for details.
0.5.1
Deprecated
- Component
avatar_pair: renamedparent_child_avatartoavatar_pair. - Components
action_menuandselect_menu: renamedis_right_alignedtois_aligned_end(added RTL support). - Component
spinner: renamedgap_colortohighlight_color.
New component
toggle_switch: Toggle switch is used to immediately toggle a setting on or off.
Updated components
avatar: Added attris_round.avatar_pair: Improved styling: support display inside flex container, add inner border to child avatar.button- Improved dimensions according to Primer Style specs, including placing a trailing icon.
- Added attr
is_aligned_start. Aligns contents to the start (at the left in left-to-right languages), while the dropdown caret (if any) is placed at the far end.
spinner: Updated to latest Primer Style design.
0.5.0
Form elements have been revamped and aligned with the most recent form element documentation at Primer Style.
Deprecated
For all listed deprecations below: existing syntax will keep working, but log warnings will inform about the deprecation.
form_groupis replaced byform_control(andis_form_groupis replaced byis_form_control). When updating your code:- You may need to add styling to correct the missing whitespace at top and bottom, because class "form-group" (which is also added when using attrs
form_groupandis_form_group) contains a top and bottom margin. - Without a form group, text inputs (as well as selects) will be given a default width by the browser and will probably be displayed smaller than they currently are.
- You may need to add styling to correct the missing whitespace at top and bottom, because class "form-group" (which is also added when using attrs
- The horizontal "tab-row" layout of
radio_groupis not mentioned in the Primer Design specification, while "Radio group" is (with vertical layout).- The current
radio_grouphas been renamed toradio_tabs. - The new component
radio_groupuses a vertical layout.
- The current
checkboxandradio_buttonslothinthas been renamed tocaption.button_groupslotbuttonis replaced bybuttoncomponents as children.- For consistency, attr
is_fullhas been renamed tois_full_width(inalertandheaderslot:item).
Improvements
- Added component
checkbox_group. - Added convenience component
checkbox_in_groupfor checkboxes inside acheckbox_group. - Added component
radio_group(with vertical layout). - Added attr
captionto show hint message below the form fields.- Implemented for
select,text_inputandtextarea. - Implemented for
checkbox_groupandradio_groupto show a hint below the group label.
- Implemented for
- Added a required marker to
form_control,checkbox_groupandradio_group. The form control label will show a required marker if the field is required.- Added
is_required?toFieldState, so it can also be queried invalidation_messageandcaptioncallbacks.
- Added
- Added disabled state to
form_control:- With components
select,text_inputandtextarea: the attributedisabledis automatically passed toform_control. - When using component
form_controlon its own: set explicitly with attris_disabled.
- With components
Removed
- Form element width variation attrs
is_shortandis_shorter. These are no longer supported by Primer System. form_controlclassbody: this extra div is removed to simplify the styling of validation states.
0.4.0
Improvements
- The open state of menus and dialogs can now be maintained when used inside forms.
- Improved validation message logic.
- Updated components:
theme_menu_options: added attrupdate_theme_event: the event name to be called for updating the theme.radio_group: added to slotradio_buttonthe attrlabelto set a custom label.
- Updated
@primer/cssto21.0.7.
Breaking changes
- Removed functions related to using session for theme state - see
PrimerLive.Themefor alternatives. Removed:ThemeSessionControllerThemeEvent- Theme hook
- IDs of checkboxes and radio buttons have been updated to only include valid characters.
Deprecated
- For all menu components, including 'dialog' and 'drawer': passing prompt options to the
toggleslot is replaced by passingprompt_optionsto the main component. - In the
drawercomponent, replace the subcomponentdrawer_contentwith the slotbody.- This allows the focus wrap ID to be derived from the drawer's 'id' attribute, similar to how it is done for 'dialog'.
- When using the previous syntax, a warning message will be shown in the shell.
Other changes
- The HTML structure and some of the CSS classes of
action_menu,dropdown_menuandselect_menuhave changed. Instead of<details>and<summary>elements, the open state is now controlled with<input type="checkbox">and<label>. - HTML attributes are sorted alphabetically.
0.3.1
Replaced underscores in HTML element attributes with dashes because Phoenix LiveView 0.19 no longer does automatic substitution.
Updated components:
select: attrpromptis ignored whenis_multipleis also used. This preventsPhoenix.HTML.Form.multiple_selectfrom raising an error.
0.3.0
Breaking change: action_list_item now always renders a checkbox group, also when is_multiple_select is set on the list items. This change makes handling form data in events more consistent: the data will always consist of a list of checkbox values.
0.2.7
Fixes a bug introduced in 0.2.6 where single select action_list_items did not get unique ids.
0.2.6
- Fixes a bug where
FormHelpers.field_statedid not handle forms without a changeset. - Updated components:
text_input: added attrsnameandvaluecheckbox: add attrschecked,checked_value,hidden_input
- Update
@primer/cssto21.0.0.
0.2.5
Updated components:
action_menuandselect_menu:- Added
promptslot attroptionsto pass Prompt options. This enables (for example) to postpone submitting a form in the menu by callingsubmitevent in the Prompt functionswillHideordidHide.
- Added
0.2.4
- Fixes a bug where variables in error messages where not interpolated.
- Update to
phoenix_html3.3.x
0.2.3
- Clarified
layoutattributes to change the rendered order of slots. - Improve field name and id generation.
- Use checkboxes and radio buttons in action lists.
Updated component:
checkbox:- Added attr
is_multiple: When creating a list of checkboxes. Appends[]to the input name so that a list of values is passed to the form events. - Added attr
is_omit_label: Omits any label.
- Added attr
0.2.2
Updated component:
text_input:- Moved attr
is_trailing_action_dividerto slottrailing_actionasis_divider - Added attr
is_visible_with_valueto slottrailing_actionto only show the trailing action when the input has a value. Use this cor example to show a clear button only when the input has a value to clear.
- Moved attr
0.2.1
Rework of form controls
The rework includes styles from Primer ViewComponents. The form styles from this flavor of Primer is more mature than the generally used Primer CSS.
Updated components:
text_input:- Added attr
is_monospace - Added slots
leading_visualandtrailing_action - Added attr
is_trailing_action_divider - Inputs inside a form group no longer have a background color by default; use
is_contrastto set it explicitly - Removed validation message for hidden inputs
- Added attr
textarea:- Added attr
is_monospace - Use
is_contrastto explicitly set a contrasting background color
- Added attr
checkboxandradio_button- Have a clearer (more colorful) appearance
- Changed the HTML structure
radio_group- For consistency, added input styling from Primer ViewComponents radio button (keeping the initial size)
select:- Added wrapper HTML element
- Added attr
is_monospace - Added attr
is_large - Added attr
is_short - Added attr
is_shorter - Added attr
is_full_width - Improved styling for multiple select
subnavwith search field:- Added attr
is_wrapto wrap child elements - Improved CSS for small screens
- Added attr
Added component:
input_validation_message- can be used as standalone message component for inputs where the position of the validation feedback is not so obvious, for example lists of checkboxes or radio buttons
Additional:
- Added styling for input elements inside a disabled fieldset
Integration of npm dependencies
JavaScript and CSS dependencies (from npm library primer-live) are now incorporated in the Elixir package. The installation instructions are slightly simplified (see the documentation) and are recommended for a fresh setup. The previous installation method works just fine for existing projects.
0.1.16
Added anchor link attributes to button to create a link that looks like a button.
0.1.15
Removed Octicon builder template files from distribution.
0.1.14
- Updated
octiconsdependency to17.10.1 - Code quality refactoring
- Documentation updates
0.1.13
Added:
theme_menu_optionsto create a theme menuTheme.html_attributesto set theme attributes on elements- Theme functions for persistent theme data in the session
0.1.12
Fixes an issue where validation messages did not show.
0.1.11
Added:
theme
0.1.10
Updated:
- Prevent attribute open on select menu
0.1.9
Added:
styled_html
0.1.8
Updated:
- Removed requirement for Elixir version
0.1.7
Updated:
- Added
is_smallfortabnavitems
0.1.6
Updated:
oticonicons
0.1.5
Added:
drawer
0.1.4
Bug fix:
- Improve
action_menuon mobile
0.1.3
Added:
action_menu
0.1.2
Bug fix:
action_link_item: pass class tolinkslot.
0.1.1
First release.