block.json
1 month ago
edit.js
1 week ago
index-min.js
1 year ago
index.js
1 year ago
save.js
1 year ago
edit.js
126 lines
| 1 | /** |
| 2 | * WordPress components that create the necessary UI elements for the block |
| 3 | * |
| 4 | * @see https://developer.wordpress.org/block-editor/packages/packages-components/ |
| 5 | */ |
| 6 | import {TextControl, Panel, PanelBody, PanelRow} from '@wordpress/components'; |
| 7 | |
| 8 | |
| 9 | /** |
| 10 | * React hook that is used to mark the block wrapper element. |
| 11 | * It provides all the necessary props like the class name. |
| 12 | * |
| 13 | * @see https://developer.wordpress.org/block-editor/reference-guides/packages/packages-block-editor/#useblockprops |
| 14 | */ |
| 15 | import { |
| 16 | useBlockProps, |
| 17 | InspectorControls, |
| 18 | } from '@wordpress/block-editor'; |
| 19 | import styled from "@emotion/styled"; |
| 20 | import IframeEmotionCacheProvider from '../utils/IframeEmotionCacheProvider'; |
| 21 | |
| 22 | |
| 23 | /** |
| 24 | * The edit function describes the structure of your block in the context of the |
| 25 | * editor. This represents what the editor will render when the block is used. |
| 26 | * |
| 27 | * @see https://developer.wordpress.org/block-editor/reference-guides/block-api/block-edit-save/#edit |
| 28 | * |
| 29 | * @param {Object} props Properties passed to the function. |
| 30 | * @param {Object} props.attributes Available block attributes. |
| 31 | * @param {Function} props.setAttributes Function that updates individual attributes. |
| 32 | * |
| 33 | * @return {WPElement} Element to render. |
| 34 | */ |
| 35 | export default function Edit({attributes, setAttributes}) { |
| 36 | const blockProps = useBlockProps(); |
| 37 | |
| 38 | const LatepointFormWrapper = styled.div` |
| 39 | box-shadow: 0px 2px 4px -1px rgba(0,0,0,0.1); |
| 40 | border-radius: 4px; |
| 41 | border: 1px solid #ddd; |
| 42 | border-bottom-color: #bbb; |
| 43 | background-color: #fff; |
| 44 | padding: 20px; |
| 45 | max-width: 300px; |
| 46 | display: flex; |
| 47 | flex-direction: column; |
| 48 | gap: 10px; |
| 49 | `; |
| 50 | |
| 51 | const LatepointBlockCaption = styled.div` |
| 52 | font-weight: 500; |
| 53 | margin-bottom: 10px; |
| 54 | font-size: 12px; |
| 55 | text-transform: uppercase; |
| 56 | letter-spacing: 1px; |
| 57 | `; |
| 58 | |
| 59 | const LatepointFormTitle = styled.div` |
| 60 | padding: 10px; |
| 61 | border-radius: 4px; |
| 62 | background-color: #eee; |
| 63 | margin-bottom: 5px; |
| 64 | width: 40%; |
| 65 | `; |
| 66 | const LatepointFormLink = styled.div` |
| 67 | height: 10px; |
| 68 | border-radius: 4px; |
| 69 | background-color: #eee; |
| 70 | width: 30%; |
| 71 | `; |
| 72 | |
| 73 | const LatepointFormInput = styled.div` |
| 74 | padding: 15px; |
| 75 | border-radius: 4px; |
| 76 | background-color: #f8f8f8; |
| 77 | `; |
| 78 | |
| 79 | const LatepointFormFooter = styled.div` |
| 80 | display: flex; |
| 81 | justify-content: space-between; |
| 82 | align-items: center; |
| 83 | gap: 20px; |
| 84 | padding-top: 10px; |
| 85 | `; |
| 86 | |
| 87 | const LatepointButtonPrev = styled.div` |
| 88 | padding: 15px; |
| 89 | width: 30%; |
| 90 | background-color: #b4c6f5; |
| 91 | border-radius: 4px; |
| 92 | `; |
| 93 | |
| 94 | return ( |
| 95 | <div {...blockProps}> |
| 96 | <InspectorControls> |
| 97 | <Panel> |
| 98 | <PanelBody title="Login Form Settings"> |
| 99 | <TextControl __nextHasNoMarginBottom __next40pxDefaultSize |
| 100 | label="Caption" |
| 101 | value={attributes.caption || ''} |
| 102 | onChange={(value) => setAttributes({caption: value})} |
| 103 | /> |
| 104 | </PanelBody> |
| 105 | </Panel> |
| 106 | </InspectorControls> |
| 107 | <IframeEmotionCacheProvider> |
| 108 | <div> |
| 109 | <LatepointBlockCaption>{attributes.caption}</LatepointBlockCaption> |
| 110 | <LatepointFormWrapper> |
| 111 | <LatepointFormTitle></LatepointFormTitle> |
| 112 | |
| 113 | <LatepointFormInput></LatepointFormInput> |
| 114 | <LatepointFormInput></LatepointFormInput> |
| 115 | |
| 116 | <LatepointFormFooter> |
| 117 | <LatepointButtonPrev></LatepointButtonPrev> |
| 118 | <LatepointFormLink></LatepointFormLink> |
| 119 | </LatepointFormFooter> |
| 120 | </LatepointFormWrapper> |
| 121 | </div> |
| 122 | </IframeEmotionCacheProvider> |
| 123 | </div> |
| 124 | ); |
| 125 | } |
| 126 |