Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Improve #96

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 16 additions & 6 deletions next-i18next.config.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,16 @@
module.exports = {
i18n: {
defaultLocale: 'zh',
locales: ['zh', 'en', 'zh-Hant'],
},
}
// settings.js

const i18nSettings = {
defaultLocale: 'zh',
locales: ['zh', 'en', 'zh-Hant'],
};

module.exports = i18nSettings;



// someOtherFile.js

const i18nSettings = require('./settings');

// usage of i18nSettings in the code
13 changes: 11 additions & 2 deletions src/components/EmojiField.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
import { Popover } from '@headlessui/react'
import EmojiPicker from 'emoji-picker-react'
import { Popover } from '@headlessui/react' // Importing Popover component from Headless UI
import EmojiPicker from 'emoji-picker-react' // Importing EmojiPicker component from emoji-picker-react

// EmojiField component receives two props: value and onChange
// value: string - the current emoji value
// onChange: (v: string) => void - a callback function to update the emoji value
export const EmojiField = ({
value,
onChange,
Expand All @@ -9,9 +12,12 @@ export const EmojiField = ({
onChange: (v: string) => void
}) => (
<>
{/* Render a Popover component from Headless UI */}
<Popover className="relative">
{/* Render Popover.Button as the trigger for the Popover component */}
<Popover.Button>
<span className="inline-flex rounded-lg bg-indigo-50 p-3 ring-4 ring-white">
{/* Display the current emoji value inside a div */}
<div
className="flex h-6 w-6 items-center justify-center"
aria-hidden="true"
Expand All @@ -21,9 +27,12 @@ export const EmojiField = ({
</span>
</Popover.Button>

{/* Render Popover.Panel to contain the EmojiPicker component */}
<Popover.Panel className="absolute z-10">
{/* Render EmojiPicker component and attach an onEmojiClick event handler */}
<EmojiPicker onEmojiClick={({ emoji }) => onChange(emoji)} />
</Popover.Panel>
</Popover>
</>
)