Skip to content

Commit

Permalink
Makes RadioGroup SSR compatible LiferayCloud#66
Browse files Browse the repository at this point in the history
  • Loading branch information
zenorocha authored and justLuiz committed Oct 9, 2019
1 parent fc0d617 commit 24e2524
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 14 deletions.
4 changes: 2 additions & 2 deletions packages/marble-radio-group/src/RadioGroup.js
Original file line number Diff line number Diff line change
Expand Up @@ -27,14 +27,14 @@ RadioGroup.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-radio-group/src/RadioGroup.soy
Original file line number Diff line number Diff line change
Expand Up @@ -4,22 +4,24 @@
*
*/
{template .render}
{@param items: list<?>}
{@param? items: list<?>}
{@param? name: string}
{@param? style: string}

<ul 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}

<li>
<input id="{$item.id}" name="{$name}" value="{$item.value}" type="radio" {$checkedAttr}>
<label for="{$item.id}">{$item.label}</label>
</li>
{/foreach}
<li>
<input id="{$item.id}" name="{$name}" value="{$item.value}" type="radio" {$checkedAttr}>
<label for="{$item.id}">{$item.label}</label>
</li>
{/foreach}
{/if}
</ul>
{/template}
13 changes: 13 additions & 0 deletions packages/marble-radio-group/test/RadioGroup.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 RadioGroup from '../src/RadioGroup';

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

0 comments on commit 24e2524

Please sign in to comment.