Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions src/PersistentCheckbox.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,13 @@ import { Component } from '@wordpress/element';

import { getValue, setValue } from './localStorage';

/**
* Renders a checkbox that persists its checked state in localStorage.
*
* Props:
* id (string): The unique ID of the checkbox. Used as the localStorage key.
* label (React.Element): The label to display next to the checkbox.
*/
export default class PersistentCheckbox extends Component {
constructor( props ) {
super( props );
Expand Down
6 changes: 6 additions & 0 deletions src/PersistentCheckboxList.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,12 @@ import md5 from 'md5';

import PersistentCheckbox from './PersistentCheckbox';

/**
* Renders a list of PersistentCheckbox components.
*
* Props:
* labels (string[]): An array of labels to render checkboxes for.
*/
export default function PersistentCheckboxList( { labels } ) {
const listId = `list-${ md5( labels.join( '' ) ) }`;
const style = { listStyleType: 'none', marginLeft: 0 };
Expand Down