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