Created
January 28, 2020 11:38
-
-
Save Peppe/4d722c3f43d0a35c07be0e32ecc24ccc to your computer and use it in GitHub Desktop.
Adding a custom version of Vaadin radio button
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import { RadioGroupElement } from "@vaadin/vaadin-radio-button/src/vaadin-radio-group"; | |
class PRadioGroup extends RadioGroupElement { | |
connectedCallback() { | |
super.connectedCallback(); | |
} | |
static get template() { | |
return RadioGroupElement.template; | |
} | |
} | |
customElements.define("p-radio-group", PRadioGroup); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import {html, PolymerElement} from '@polymer/polymer/polymer-element.js'; | |
import '@vaadin/vaadin-ordered-layout/src/vaadin-vertical-layout.js'; | |
import '@vaadin/vaadin-radio-button/src/vaadin-radio-button.js'; | |
import '@vaadin/vaadin-radio-button/src/vaadin-radio-group.js'; | |
import '../components/p-radio-group.js'; | |
import '../components/p-radio-button.js'; | |
class PlaygroundView extends PolymerElement { | |
static get template() { | |
return html` | |
<style include="shared-styles"> | |
:host { | |
display: block; | |
height: 100%; | |
} | |
</style> | |
<vaadin-vertical-layout style="width: 100%; height: 100%;"> | |
<span>Vaadin radio group</span> | |
<vaadin-radio-group theme="" value="on"> | |
<vaadin-radio-button checked> | |
<b>Turku</b> | |
<div> | |
Development | |
</div> | |
</vaadin-radio-button> | |
<vaadin-radio-button> | |
<b>Berlin</b> | |
<div> | |
Customer Success | |
</div> | |
</vaadin-radio-button> | |
<vaadin-radio-button> | |
<b>San Jose</b> | |
<div> | |
Growth | |
</div> | |
</vaadin-radio-button> | |
</vaadin-radio-group> | |
<span>P radio group</span> | |
<p-radio-group theme="" value="on"> | |
<p-radio-button checked> | |
<b>Turku</b> | |
<div> | |
Development | |
</div> | |
</p-radio-button> | |
<p-radio-button> | |
<b>Berlin</b> | |
<div> | |
Customer Success | |
</div> | |
</p-radio-button> | |
<p-radio-button> | |
<b>San Jose</b> | |
<div> | |
Growth | |
</div> | |
</p-radio-button> | |
</p-radio-group> | |
</vaadin-vertical-layout> | |
`; | |
} | |
static get is() { | |
return 'playground-view'; | |
} | |
static get properties() { | |
return { | |
// Declare your properties here. | |
}; | |
} | |
} | |
customElements.define(PlaygroundView.is, PlaygroundView); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package com.jensjansson.kuha.views.crud; | |
import com.jensjansson.kuha.MainView; | |
import com.jensjansson.kuha.components.PRadioButtonGroup; | |
import com.vaadin.flow.component.Tag; | |
import com.vaadin.flow.component.dependency.JsModule; | |
import com.vaadin.flow.component.polymertemplate.Id; | |
import com.vaadin.flow.component.polymertemplate.PolymerTemplate; | |
import com.vaadin.flow.router.AfterNavigationEvent; | |
import com.vaadin.flow.router.AfterNavigationObserver; | |
import com.vaadin.flow.router.PageTitle; | |
import com.vaadin.flow.router.Route; | |
import com.vaadin.flow.templatemodel.TemplateModel; | |
@Route(value = "playground", layout = MainView.class) | |
@PageTitle("Playground") | |
@JsModule("/src/views/playground-view.js") | |
@Tag("playground-view") | |
public class PlaygroundView extends PolymerTemplate<PlaygroundView.PlaygroundModel> | |
implements AfterNavigationObserver { | |
@Id("pRadioGroup") | |
private PRadioButtonGroup pRadioGroup; | |
@Override | |
public void afterNavigation(AfterNavigationEvent afterNavigationEvent) { | |
pRadioGroup.addClassName("test-class"); | |
} | |
public static interface PlaygroundModel extends TemplateModel { | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment