This file contains hidden or 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 { LitElement, html, unsafeCSS } from 'lit-element'; | |
| import style from './scss/style.scss'; | |
| @customElement('some-component') | |
| export default class SomeComponent extends LitElement { | |
| static get styles() { | |
| return [ | |
| // If you don't need to consider IE, you can use a link tag to include style in the render function. | |
| unsafeCSS(style), | |
| ] |
This file contains hidden or 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
| <script type="text/javascript"> | |
| // Write me in the head tag. | |
| // For this sample, you need to put `@webcomponents/webcomponentsjs/` dirctory from the node_modules into `your-doc-root/js/` dirctory. | |
| (function() { | |
| if (('customElements' in window)) { | |
| document.write('<script defer type="text/javascript" src="/js/main.js"><\/script>'); | |
| } else { | |
| document.write('<script defer type="text/javascript" src="/js/@webcomponents/webcomponentsjs/webcomponents-loader.js"><\/script>'); | |
| window.WebComponents = window.WebComponents || {}; | |
| window.WebComponents.root = '/js/@webcomponents/webcomponentsjs/'; |
This file contains hidden or 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
| function calcOffset(elm: HTMLElement) { | |
| const offset = { | |
| top: 0, | |
| left: 0, | |
| } | |
| do { | |
| offset.top += elm.offsetTop || 0; | |
| offset.left += elm.offsetLeft || 0; | |
| } while((elm = elm.offsetParent as HTMLElement)); |
This file contains hidden or 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
| <?php | |
| add_action('wp_head', function() { | |
| $paged = get_query_var('paged'); | |
| }); |
This file contains hidden or 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
| <?php | |
| add_action( 'wp_head', function() { | |
| if(!(is_single() || is_page())){ | |
| return; | |
| } | |
| $value = get_post_meta(get_the_ID(), 'is_noindex', true ); | |
| if(!((int)$value)) { | |
| return; | |
| } | |
| wp_no_robots(); |
This file contains hidden or 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
| function addPrefixToName(WrappedComponent, prefix) { | |
| return class extends WrappedComponent { | |
| render() { | |
| const wrappedTree = super.render() | |
| let newProps = {} | |
| if (wrappedTree && wrappedTree.type === 'input') { | |
| newProps = {name: `${prefix}-${wrappedTree.props.name}`} | |
| } | |
| const props = { ...wrappedTree.props, ...newProps } // Object.assign({}, wrappedTree.props, newProps) と同様 | |
| const newTree = React.cloneElement(wrappedTree, props, wrappedTree.props.children) |
This file contains hidden or 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
| function showMessageWhenDataIsEmpty(WrappedComponent) { | |
| return class extends WrappedComponent { | |
| render() { | |
| if (this.props.data.length > 0) { // データが存在するときだけ表示 | |
| return super.render() | |
| } | |
| else { | |
| return <span>データが存在しません!</span> | |
| } | |
| } |
This file contains hidden or 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
| function withSubscription(WrappedComponent, selectData) { | |
| return class extends WrappedComponent { | |
| constructor(props) { | |
| super(props) | |
| this.handleChange = this.handleChange.bind(this) | |
| this.state = { | |
| data: selectData(DataSource, props) | |
| } | |
| } | |
This file contains hidden or 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
| function withSubscription(WrappedComponent, selectData) { | |
| return class extends React.Component { | |
| constructor(props) { | |
| super(props) | |
| this.handleChange = this.handleChange.bind(this) | |
| this.state = { | |
| data: selectData(DataSource, props) | |
| } | |
| } | |
This file contains hidden or 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
| function withSubscription(WrappedComponent, selectData) { | |
| return class extends React.Component { | |
| constructor(props) { | |
| super(props) | |
| this.handleChange = this.handleChange.bind(this) | |
| this.state = { | |
| data: selectData(DataSource, props) | |
| } | |
| } | |