Skip to content
This repository has been archived by the owner on Oct 8, 2024. It is now read-only.

Commit

Permalink
Makes CheckboxGroup SSR compatible #66
Browse files Browse the repository at this point in the history
  • Loading branch information
zenorocha committed Feb 17, 2018
1 parent 72eb2ab commit 518b757
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 14 deletions.
4 changes: 2 additions & 2 deletions packages/marble-checkbox-group/src/CheckboxGroup.js
Original file line number Diff line number Diff line change
Expand Up @@ -27,14 +27,14 @@ CheckboxGroup.STATE = {
label: Config.string(),
value: Config.string(),
})
).required(),
),

/**
* The name param used on each radio
* @type {?String}
* @default undefined
*/
name: Config.string().required(),
name: Config.string(),

/**
* The style of the radio group
Expand Down
26 changes: 14 additions & 12 deletions packages/marble-checkbox-group/src/CheckboxGroup.soy
Original file line number Diff line number Diff line change
Expand Up @@ -4,22 +4,24 @@
* This renders the component's whole content.
*/
{template .render}
{@param items: list<?>}
{@param? items: list<?>}
{@param? name: string}
{@param? style: string}

<div class="{$style}">
{foreach $item in $items}
{let $checkedAttr kind="attributes"}
{if $item.checked}
checked="checked"
{/if}
{/let}
{if $items}
{foreach $item in $items}
{let $checkedAttr kind="attributes"}
{if $item.checked}
checked="checked"
{/if}
{/let}

<div class="checkbox">
<input id="{$item.id}" name="{$name}" value="{$item.value}" type="checkbox" {$checkedAttr}>
<label for="{$item.id}">{$item.label}</label>
</div>
{/foreach}
<div class="checkbox">
<input id="{$item.id}" name="{$name}" value="{$item.value}" type="checkbox" {$checkedAttr}>
<label for="{$item.id}">{$item.label}</label>
</div>
{/foreach}
{/if}
</div>
{/template}
13 changes: 13 additions & 0 deletions packages/marble-checkbox-group/test/CheckboxGroup.node.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
/**
* @jest-environment node
*/

import Component from 'metal-component';
import CheckboxGroup from '../src/CheckboxGroup';

describe('CheckboxGroup.node', () => {
it('should not fail on the server side', () => {
const checkboxGroup = Component.renderToString(CheckboxGroup);
expect(checkboxGroup).not.toBeNull();
});
});

0 comments on commit 518b757

Please sign in to comment.