Skip to content

Commit

Permalink
update layout
Browse files Browse the repository at this point in the history
  • Loading branch information
gigitux committed Oct 23, 2024
1 parent f53239c commit 075a2b0
Show file tree
Hide file tree
Showing 3 changed files with 38 additions and 19 deletions.
2 changes: 1 addition & 1 deletion packages/fields/src/fields/slug/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ import SlugView from './slug-view';
const slugField: Field< BasePost > = {
id: 'slug',
type: 'text',
label: __( 'Link' ),
label: __( 'Slug' ),
getValue: ( { item } ) => item.slug,
Edit: SlugEdit,
render: SlugView,
Expand Down
45 changes: 30 additions & 15 deletions packages/fields/src/fields/slug/slug-edit.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import {
__experimentalVStack as VStack,
} from '@wordpress/components';
import { copySmall } from '@wordpress/icons';
import { useCopyToClipboard } from '@wordpress/compose';
import { useCopyToClipboard, useInstanceId } from '@wordpress/compose';
import { useDispatch } from '@wordpress/data';
import { useCallback, useEffect, useRef } from '@wordpress/element';
import { store as noticesStore } from '@wordpress/notices';
Expand Down Expand Up @@ -61,19 +61,24 @@ const SlugEdit = ( {
const { createNotice } = useDispatch( noticesStore );

const copyButtonRef = useCopyToClipboard( permalink, () => {
createNotice( 'info', __( 'Copied URL to clipboard.' ), {
createNotice( 'info', __( 'Copied Permalink to clipboard.' ), {
isDismissible: true,
type: 'snackbar',
} );
} );

const postUrlSlugDescriptionId =
'editor-post-url__slug-description-' + useInstanceId( SlugEdit );

return (
<fieldset className="fields-controls__slug">
{ isEditable && (
<VStack>
<VStack spacing="0px">
<span>
{ __( 'Customize the last part of the URL.' ) }
{ __(
'Customize the last part of the Permalink.'
) }
</span>
<ExternalLink href="https://wordpress.org/documentation/article/page-post-settings-sidebar/#permalink">
{ __( 'Learn more' ) }
Expand Down Expand Up @@ -109,19 +114,29 @@ const SlugEdit = ( {
onChangeControl( originalSlug.current );
}
} }
aria-describedby={ postUrlSlugDescriptionId }
help={
<ExternalLink
className="fields-controls__slug-help"
href={ permalink }
>
<span>{ permalinkPrefix }</span>
<span className="fields-controls__slug-help-slug">
{ slugToDisplay }
</span>
<span className="fields-controls__slug-help-suffix">
{ permalinkSuffix }
</span>
</ExternalLink>
<>
<p className="fields-controls__slug-help">
<span className="fields-controls__slug-help-visual-label">
{ __( 'Permalink:' ) }
</span>
<ExternalLink
className="fields-controls__slug-help-link"
href={ permalink }
>
<span className="fields-controls__slug-help-prefix">
{ permalinkPrefix }
</span>
<span className="fields-controls__slug-help-slug">
{ slugToDisplay }
</span>
<span className="fields-controls__slug-help-suffix">
{ permalinkSuffix }
</span>
</ExternalLink>
</p>
</>
}
/>
</VStack>
Expand Down
10 changes: 7 additions & 3 deletions packages/fields/src/fields/slug/style.scss
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,15 @@
padding-inline-start: 0 !important;
}

.fields-controls__slug-help-link {
word-break: break-word;
}

.fields-controls__slug-help {
color: $gray-700;
display: flex;
flex-direction: column;

.fields-controls__slug-help-slug,
.fields-controls__slug-help-suffix {
.fields-controls__slug-help-slug {
font-weight: 600;
}
}
Expand Down

0 comments on commit 075a2b0

Please sign in to comment.