0.41.0
5 years ago
component-deprecated-id.js
5 years ago
component-deprecated-noopenernoreferer-id.js
5 years ago
component-deprecated-span-to-div.js
5 years ago
component-deprecated-subcaption-noNoopnnernoreferer-id.js
5 years ago
component-deprecated.js
5 years ago
componentV1.js
5 years ago
deprecated.js
5 years ago
componentV1.js
111 lines
| 1 | const { Component } = wp.element; |
| 2 | |
| 3 | export class VKBButtonV1 extends Component { |
| 4 | |
| 5 | render() { |
| 6 | |
| 7 | const buttonColorCustom = this.props.lbColorCustom; |
| 8 | const buttonColor = this.props.lbColor; |
| 9 | const buttonType = this.props.lbType; |
| 10 | const buttonAlign = this.props.lbAlign; |
| 11 | const buttonSize = this.props.lbSize; |
| 12 | const buttonUrl = this.props.lbUrl; |
| 13 | const buttonTarget = this.props.lbTarget; |
| 14 | const fontAwesomeIconBefore = this.props.lbFontAwesomeIconBefore; |
| 15 | const fontAwesomeIconAfter = this.props.lbFontAwesomeIconAfter; |
| 16 | const richText = this.props.lbRichtext; |
| 17 | const subCaption = this.props.lbsubCaption; |
| 18 | const containerClass = ''; |
| 19 | let aClass = ''; |
| 20 | let aStyle = {}; |
| 21 | let iconBefore = ''; |
| 22 | let iconAfter = ''; |
| 23 | |
| 24 | aStyle = null; |
| 25 | aClass = `vk_button_link`; |
| 26 | |
| 27 | if (buttonType == '0' || buttonType == null || buttonType == '1') { |
| 28 | aClass = `${aClass} btn`; |
| 29 | } else { |
| 30 | aClass = `${aClass} vk_button_link-type-text`; |
| 31 | } |
| 32 | |
| 33 | // 塗り |
| 34 | if (buttonType == '0' || buttonType === null) { |
| 35 | |
| 36 | // 規定カラーの場合 |
| 37 | if (buttonColorCustom == 'undefined' || buttonColorCustom == undefined || buttonColorCustom === null) { |
| 38 | |
| 39 | aClass = `${aClass} btn-${buttonColor}`; |
| 40 | aStyle = null; |
| 41 | |
| 42 | // カスタムカラーの場合 |
| 43 | } else { |
| 44 | aStyle = { |
| 45 | backgroundColor: buttonColorCustom, |
| 46 | border: `1px solid ${buttonColorCustom}`, |
| 47 | color: `#fff`, |
| 48 | }; |
| 49 | } |
| 50 | // 塗りなし |
| 51 | } else if (buttonType === '1') { |
| 52 | // 規定カラーの場合 |
| 53 | if (buttonColorCustom == 'undefined' || buttonColorCustom == undefined || buttonColorCustom === null) { |
| 54 | aClass = `${aClass} btn-outline-${buttonColor}`; |
| 55 | aStyle = null; |
| 56 | // カスタムカラーの場合 |
| 57 | } else { |
| 58 | aStyle = { |
| 59 | backgroundColor: 'transparent', |
| 60 | border: '1px solid ' + buttonColorCustom, |
| 61 | color: buttonColorCustom, |
| 62 | }; |
| 63 | } |
| 64 | // テキストのみ |
| 65 | } else if (buttonType === '2') { |
| 66 | // 規定カラーの場合 |
| 67 | if (buttonColorCustom == 'undefined' || buttonColorCustom == undefined || buttonColorCustom === null) { |
| 68 | aClass = `${aClass} btn-outline-${buttonColor}`; |
| 69 | aStyle = null; |
| 70 | // カスタムカラーの場合 |
| 71 | } else { |
| 72 | aStyle = { |
| 73 | color: buttonColorCustom, |
| 74 | }; |
| 75 | } |
| 76 | } |
| 77 | |
| 78 | aClass = `${aClass} btn-${buttonSize}`; |
| 79 | |
| 80 | if (buttonAlign === 'block') { |
| 81 | aClass = `${aClass} btn-block`; |
| 82 | } |
| 83 | if (fontAwesomeIconBefore) { |
| 84 | iconBefore = <i className={ `${fontAwesomeIconBefore} vk_button_link_before` }></i>; |
| 85 | } |
| 86 | if (fontAwesomeIconAfter) { |
| 87 | iconAfter = <i className={ `${fontAwesomeIconAfter} vk_button_link_after` }></i>; |
| 88 | } |
| 89 | |
| 90 | return ( |
| 91 | <a |
| 92 | href={ buttonUrl } |
| 93 | id={ 'vk_button_link' } |
| 94 | style={ aStyle } |
| 95 | className={ aClass } |
| 96 | role={ 'button' } |
| 97 | aria-pressed={ true } |
| 98 | target={ buttonTarget ? '_blank' : null } |
| 99 | rel={ 'noopener noreferrer' } |
| 100 | > |
| 101 | { iconBefore } |
| 102 | { richText } |
| 103 | { iconAfter } |
| 104 | { /*サブキャプションが� |
| 105 | �力された時のみ表示*/ } |
| 106 | { subCaption && <p className={ 'vk_button_link_subCaption' }>{ subCaption }</p> } |
| 107 | </a> |
| 108 | ); |
| 109 | } |
| 110 | } |
| 111 |