From 544f826315e81db86ea0b38f646e2c3bc47b9b22 Mon Sep 17 00:00:00 2001 From: Peter Zimon Date: Tue, 23 May 2023 17:22:30 +0200 Subject: [PATCH] Added basic Twitter card in AdminX Settings refs. https://github.com/TryGhost/Team/issues/3150 --- .../settings/general/GeneralSettings.tsx | 2 + .../components/settings/general/Twitter.tsx | 68 +++++++++++++++++++ 2 files changed, 70 insertions(+) create mode 100644 ghost/admin-x-settings/src/components/settings/general/Twitter.tsx diff --git a/ghost/admin-x-settings/src/components/settings/general/GeneralSettings.tsx b/ghost/admin-x-settings/src/components/settings/general/GeneralSettings.tsx index 669cc69800..508f05ebe8 100644 --- a/ghost/admin-x-settings/src/components/settings/general/GeneralSettings.tsx +++ b/ghost/admin-x-settings/src/components/settings/general/GeneralSettings.tsx @@ -8,6 +8,7 @@ import SettingSection from '../../../admin-x-ds/settings/SettingSection'; import SocialAccounts from './SocialAccounts'; import TimeZone from './TimeZone'; import TitleAndDescription from './TitleAndDescription'; +import Twitter from './Twitter'; import Users from './Users'; const GeneralSettings: React.FC = () => { @@ -18,6 +19,7 @@ const GeneralSettings: React.FC = () => { + diff --git a/ghost/admin-x-settings/src/components/settings/general/Twitter.tsx b/ghost/admin-x-settings/src/components/settings/general/Twitter.tsx new file mode 100644 index 0000000000..d6b0a43bae --- /dev/null +++ b/ghost/admin-x-settings/src/components/settings/general/Twitter.tsx @@ -0,0 +1,68 @@ +import React from 'react'; +import SettingGroup from '../../../admin-x-ds/settings/SettingGroup'; +import SettingGroupContent from '../../../admin-x-ds/settings/SettingGroupContent'; +import TextField from '../../../admin-x-ds/global/TextField'; +import useSettingGroup from '../../../hooks/useSettingGroup'; + +const Twitter: React.FC = () => { + const { + currentState, + focusRef, + handleSave, + handleCancel, + updateSetting, + getSettingValues, + handleStateChange + } = useSettingGroup(); + + const [twitterTitle, twitterDescription, siteTitle, siteDescription] = getSettingValues(['twitter_title', 'twitter_description', 'title', 'description']) as string[]; + + const handleTitleChange = (e: React.ChangeEvent) => { + updateSetting('twitter_title', e.target.value); + }; + + const handleDescriptionChange = (e: React.ChangeEvent) => { + updateSetting('twitter_description', e.target.value); + }; + + const values = ( +
+ [TBD: twitter card preview] +
+ ); + + const inputFields = ( + + + + + ); + + return ( + + {values} + {currentState !== 'view' ? inputFields : ''} + + ); +}; + +export default Twitter; \ No newline at end of file