From 14557efef5f70b12a033fd476db9a2e1d4ca42ec Mon Sep 17 00:00:00 2001 From: lightbulbman Date: Sat, 18 Jan 2025 22:52:21 +0000 Subject: [PATCH 1/6] feature: add name atts --- src/js/components/SnippetForm/fields/ScopeInput.tsx | 2 ++ src/js/types/Shortcodes.ts | 1 + src/js/utils/text.ts | 7 +++++++ 3 files changed, 10 insertions(+) diff --git a/src/js/components/SnippetForm/fields/ScopeInput.tsx b/src/js/components/SnippetForm/fields/ScopeInput.tsx index bc1c5659..7ef9ae4f 100644 --- a/src/js/components/SnippetForm/fields/ScopeInput.tsx +++ b/src/js/components/SnippetForm/fields/ScopeInput.tsx @@ -7,6 +7,7 @@ import { buildShortcodeTag } from '../../../utils/shortcodes' import { getSnippetType } from '../../../utils/snippets' import { CopyToClipboardButton } from '../../common/CopyToClipboardButton' import { useSnippetForm } from '../../../hooks/useSnippetForm' +import { truncateWords } from '../../../utils/text' import type { ShortcodeAtts } from '../../../utils/shortcodes' import type { SnippetScope } from '../../../types/Snippet' import type { Dispatch, SetStateAction} from 'react' @@ -117,6 +118,7 @@ const ShortcodeInfo: React.FC = () => { <> diff --git a/src/js/types/Shortcodes.ts b/src/js/types/Shortcodes.ts index 013ea7de..edb63d99 100644 --- a/src/js/types/Shortcodes.ts +++ b/src/js/types/Shortcodes.ts @@ -5,6 +5,7 @@ export interface SourceShortcodeAtts { export interface ContentShortcodeAtts { id: string + name: string php: boolean format: boolean shortcodes: boolean diff --git a/src/js/utils/text.ts b/src/js/utils/text.ts index 590dac66..98376115 100644 --- a/src/js/utils/text.ts +++ b/src/js/utils/text.ts @@ -6,3 +6,10 @@ export const trimLeadingChar = (text: string, character: string): string => export const trimTrailingChar = (text: string, character: string): string => character === text.charAt(text.length - 1) ? text.slice(0, -1) : text + +export const truncateWords = (text: string, wordCount: number = 3): string => { + const words = text.trim().split(/\s+/); + return words.length > wordCount + ? `${words.slice(0, wordCount).join(' ')}...` + : text; +}; \ No newline at end of file From 24b61513ba3f437ce6d84b9964aabcd308871063 Mon Sep 17 00:00:00 2001 From: lightbulbman Date: Sat, 18 Jan 2025 23:32:32 +0000 Subject: [PATCH 2/6] feature: sticky-admin-notice --- src/css/edit.scss | 6 ++++++ src/js/components/SnippetForm/page/Notices.tsx | 17 ++++++++++++----- 2 files changed, 18 insertions(+), 5 deletions(-) diff --git a/src/css/edit.scss b/src/css/edit.scss index 546c2660..036e4dec 100644 --- a/src/css/edit.scss +++ b/src/css/edit.scss @@ -152,3 +152,9 @@ p.snippet-scope, .snippet-scope p { .wrap .notice { scroll-margin: 0.75em; } + +#edit-snippet-form-container .cs-sticky-notice { + position: sticky; + top: 40px; + z-index: 100; +} diff --git a/src/js/components/SnippetForm/page/Notices.tsx b/src/js/components/SnippetForm/page/Notices.tsx index 43d5eaae..7c519df4 100644 --- a/src/js/components/SnippetForm/page/Notices.tsx +++ b/src/js/components/SnippetForm/page/Notices.tsx @@ -8,17 +8,23 @@ interface DismissibleNoticeProps { classNames?: classnames.Argument onRemove: MouseEventHandler children?: ReactNode + autoHide?: boolean } -const DismissibleNotice: React.FC = ({ classNames, onRemove, children }) => { +const DismissibleNotice: React.FC = ({ classNames, onRemove, children, autoHide = true }) => { useEffect(() => { - if (window.CODE_SNIPPETS_EDIT?.scrollToNotices) { - window.scrollTo({ top: 0, behavior: 'smooth' }) + if (autoHide) { + const timer = setTimeout(() => { + onRemove({} as React.MouseEvent) + }, 5000) + + return () => clearTimeout(timer) } - }, []) + return () => {} // eslint-disable-line + }, [autoHide, onRemove]) return ( -
+
<>{children} From f4423991b2f9e286aa084b34412577d1e3a07c4f Mon Sep 17 00:00:00 2001 From: lightbulbman Date: Thu, 23 Jan 2025 00:23:54 +0000 Subject: [PATCH 6/6] remove box shadow toggle --- src/css/manage.scss | 6 ------ 1 file changed, 6 deletions(-) diff --git a/src/css/manage.scss b/src/css/manage.scss index 9379a872..cfd55920 100644 --- a/src/css/manage.scss +++ b/src/css/manage.scss @@ -60,12 +60,6 @@ $inactive-color: #ccc; height: 17px; border-radius: 34px; background-color: #ccc; - box-shadow: 0 0px 1px 0px rgba(0, 0, 0, .2); - transition: all 200ms ease-in-out !important; - - &:hover { - box-shadow: 0 1px 3px 0px rgba(0, 0, 0, 0.5); - } &::before { transition: all .4s;