diff --git a/.gitignore b/.gitignore index 69d7ceb8..fb1e9718 100644 --- a/.gitignore +++ b/.gitignore @@ -20,6 +20,7 @@ vendor/ /plugins/*/ # Except for the ones in this repo !/plugins/wp-test-plugin/ +!/plugins/wptelegram-comments/ # Build tools/IDEs .rollup.cache/ diff --git a/.vscode/extensions.json b/.vscode/extensions.json index ac72c25f..2abbf999 100644 --- a/.vscode/extensions.json +++ b/.vscode/extensions.json @@ -4,4 +4,4 @@ "bmewburn.vscode-intelephense-client", "biomejs.biome" ] -} \ No newline at end of file +} diff --git a/.vscode/settings.json b/.vscode/settings.json index 34632e38..58b90f6e 100644 --- a/.vscode/settings.json +++ b/.vscode/settings.json @@ -13,4 +13,4 @@ "quickfix.biome": "explicit", "source.organizeImports.biome": "explicit" } -} \ No newline at end of file +} diff --git a/packages/js/adapters/ColorPicker/ColorInputPicker.tsx b/packages/js/adapters/ColorPicker/ColorInputPicker.tsx new file mode 100644 index 00000000..45cf087f --- /dev/null +++ b/packages/js/adapters/ColorPicker/ColorInputPicker.tsx @@ -0,0 +1,81 @@ +import { + Button, + ButtonProps, + InputAddonProps, + InputProps, + Popover, + PopoverBody, + PopoverContent, + PopoverTrigger, +} from '@chakra-ui/react'; +import { useCallback, useMemo, useState } from 'react'; +import { TextInput } from '../Input'; +import { useDebouncedCallback } from '../hooks'; +import { ColorPicker, ColorPickerProps } from './ColorPicker'; + +const addonBeforeProps: InputAddonProps = { px: '0px', py: '0px' }; + +export const ColorInputPicker: React.FC = ({ + value, + onChange, + ...props +}) => { + const [currentColor, setCurrentColor] = useState(value || ''); + + const buttonProps = useMemo( + () => ({ backgroundColor: currentColor }), + [currentColor], + ); + + const onChangeInput = useCallback>( + (event) => { + const newColor = event.target.value; + + onChange?.(newColor); + setCurrentColor(newColor); + }, + [onChange], + ); + + const onChangeColor = useCallback( + (newColor: string) => { + onChange?.(newColor); + setCurrentColor(newColor); + }, + [onChange], + ); + + const debouncedOnChangeColor = useDebouncedCallback(onChangeColor, 200); + + return ( + + + + + + + + + ); +}; diff --git a/packages/js/components/Description.tsx b/packages/js/components/Description.tsx new file mode 100644 index 00000000..60e6a6c1 --- /dev/null +++ b/packages/js/components/Description.tsx @@ -0,0 +1,9 @@ +import { Text, TextProps } from '@wpsocio/adapters'; + +export const Description: React.FC = ({ children, ...props }) => { + return ( + + {children} + + ); +}; diff --git a/packages/js/components/InstructionsLink.tsx b/packages/js/components/InstructionsLink.tsx new file mode 100644 index 00000000..86afe6c1 --- /dev/null +++ b/packages/js/components/InstructionsLink.tsx @@ -0,0 +1,17 @@ +import { Link } from '@wpsocio/adapters'; +import { __ } from '@wpsocio/i18n'; + +interface InstructionsLinkProps { + link: string; + text?: string; +} + +export const InstructionsLink: React.FC< + React.PropsWithChildren +> = ({ link, text, children }) => { + return ( + + {text || children || __('Click here for instructions.')} + + ); +}; diff --git a/packages/js/components/Smile.tsx b/packages/js/components/Smile.tsx new file mode 100644 index 00000000..7147fece --- /dev/null +++ b/packages/js/components/Smile.tsx @@ -0,0 +1,7 @@ +export const Smile = () => { + return ( + + 🙂 + + ); +}; diff --git a/packages/js/components/VerticalDivider.tsx b/packages/js/components/VerticalDivider.tsx new file mode 100644 index 00000000..ed08eab9 --- /dev/null +++ b/packages/js/components/VerticalDivider.tsx @@ -0,0 +1,30 @@ +import { Box, Flex } from '@wpsocio/adapters'; + +export interface VerticalDividerProps { + height?: string; +} + +export const VerticalDivider: React.FC< + React.PropsWithChildren +> = ({ children, height = '1em' }) => { + const divider = ( + + ); + return ( + + {divider} + {children} + {divider} + + ); +}; diff --git a/packages/js/components/YouTubeVideo.tsx b/packages/js/components/YouTubeVideo.tsx new file mode 100644 index 00000000..6f534523 --- /dev/null +++ b/packages/js/components/YouTubeVideo.tsx @@ -0,0 +1,53 @@ +import type { CSSProperties } from 'react'; + +import { Box } from '@wpsocio/adapters'; + +type YouTubeVideoProps = { + videoId: string; + title: string; + asGridCol?: boolean; +}; + +const parentStyle: CSSProperties = { + position: 'relative', + paddingBottom: '56.25%' /* 16:9 */, + paddingTop: 25, + height: 0, +}; + +const iframeStyle: CSSProperties = { + position: 'absolute', + top: 0, + left: 0, + width: '100%', + height: '100%', +}; + +const gridColMS = { sm: '', md: 'auto' }; + +export const YouTubeVideo: React.FC = ({ + videoId, + title, + asGridCol, +}) => { + const output = ( + +