Skip to content

Instantly share code, notes, and snippets.

@chillu
Last active March 21, 2019 02:31
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save chillu/d0aee222df9039ad267ea7d4bc9c2bf9 to your computer and use it in GitHub Desktop.
Save chillu/d0aee222df9039ad267ea7d4bc9c2bf9 to your computer and use it in GitHub Desktop.
Design System Brainstorm
<!-- See https://github.com/silverstripe/cwp-starter-theme/blob/master/templates/Includes/AriaAttributes.ss -->
<% if $Message || $Description %>
aria-describedby="<% if $Message %>message-$ID<% end_if %><% if $Description %><% if $Message %> <% end_if %>describes-$ID<% end_if %>"
<% end_if %>
<% if $Title || $RightTitle %>
aria-labelledby="<% if $Title %>title-$ID<% end_if %><% if $RightTitle %><% if $Title %> <% end_if %>extra-label-$ID<% end_if %>"
<% end_if %>
<% component GridRow %>
$Block
</% end_component %>
<div class="design-system-flexbox" cols="$cols">
<!-- See https://github.com/symbiote/silverstripe-components --!>
$children
</div>
<?php
class NewsletterSignupBlock extends BaseElement {
public function Form()
{
// Should live in controller, for demo purposes only
$fields = new FieldList([
new TextField('MyTextField')
]);
$actions = new FieldList([
new FormAction('submit')
])
return new Form(Controller::curr(), 'Form', $fields, $actions);
}
}
<% with Form %>
<!-- See https://docs.silverstripe.org/en/4/developer_guides/forms/how_tos/lightweight_form/ -->
<form $FormAttributes>
<% component GridCol cols=6 %>
<!-- theoretical-bind-to doesn't exist -->
<% component TextField theoretical-bind-to="MyTextField" class="my-extra-class" my-design-system-attribute=true /%>
<!-- alternative way, which exists, renders TextField.ss, but doesn't allow custom arguments -->
$FieldMap.MyTextField
<% end_component %>
<% component GridCol cols=6 %>
<% component FormAction theoretical-bind-to="submit" class="my-extra-class" my-design-system-attribute=true /%>
<% end_component %>
</form>
<% end_with>
<% component Grid cols=12 %>
<% loop $Blocks %>
$BlockHolder
<% end_loop %>
<% end_component %>
<!-- Default template from starter theme, with additional classes. -->
<!-- See https://github.com/silverstripe/cwp-starter-theme/blob/master/templates/SilverStripe/Forms/TextField.ss -->
<!-- See https://github.com/silverstripe/silverstripe-framework/blob/4/src/Forms/FormField.php#L713 for getAttributesHTML implementation -->
<input $getAttributesHTML('class') class="$ExtraClass.ATT form-control" <% include AriaAttributes %> />
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment