-
Notifications
You must be signed in to change notification settings - Fork 44
feat: preferences settings revamp #1483
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
Merged
Merged
Changes from all commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
66f576d
chore: use apsara v1 in sdk
rohanchkrabrty b6b1082
feat: general page revamp
rohanchkrabrty fd07c82
feat: preferences page revamp
rohanchkrabrty eded8b8
Merge branch 'main' into feat-profilw-revamp
rohanchkrabrty 93f25a1
Merge branch 'main' into feat-profilw-revamp
rohanchkrabrty File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,5 @@ | ||
| import { PreferencesView } from '@raystack/frontier/react'; | ||
|
|
||
| export default function Preferences() { | ||
| return <PreferencesView />; | ||
| } | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -7,6 +7,5 @@ | |
| } | ||
|
|
||
| .content { | ||
| max-width: 1512px; | ||
| width: 100%; | ||
| } | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
46 changes: 46 additions & 0 deletions
46
web/sdk/react/views-new/preferences/components/preference-row.tsx
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,46 @@ | ||
| import { ComponentProps } from 'react'; | ||
| import { Flex, Text, Skeleton } from '@raystack/apsara-v1'; | ||
| import styles from './preferences-row.module.css'; | ||
| import { cx } from 'class-variance-authority'; | ||
|
|
||
| export interface PreferenceRowProps extends ComponentProps<typeof Flex> { | ||
| title: string; | ||
| description: string; | ||
| isLoading?: boolean; | ||
| contentProps?: ComponentProps<typeof Flex>; | ||
| } | ||
|
|
||
| export function PreferenceRow({ | ||
| title, | ||
| description, | ||
| isLoading, | ||
| children, | ||
| className, | ||
| contentProps, | ||
| ...props | ||
| }: PreferenceRowProps) { | ||
| return ( | ||
| <Flex align="center" gap={9} className={cx(styles.row, className)} {...props}> | ||
| <Flex direction="column" gap={3} className={styles.content}> | ||
| {isLoading ? ( | ||
| <> | ||
| <Skeleton width="20%" height={24} /> | ||
| <Skeleton width="40%" height={16} /> | ||
| </> | ||
| ) : ( | ||
| <> | ||
| <Text size="large" weight="medium"> | ||
| {title} | ||
| </Text> | ||
| <Text size="small" variant="secondary"> | ||
| {description} | ||
| </Text> | ||
| </> | ||
| )} | ||
| </Flex> | ||
| <Flex {...contentProps} className={cx(styles.children, contentProps?.className)}> | ||
| {isLoading ? <Skeleton width={135} height={33} /> : children} | ||
| </Flex> | ||
| </Flex> | ||
| ); | ||
| } |
10 changes: 10 additions & 0 deletions
10
web/sdk/react/views-new/preferences/components/preferences-row.module.css
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,10 @@ | ||
| .row { | ||
| padding: var(--rs-space-7) 0; | ||
| border-bottom: 1px dashed var(--rs-color-border-base-primary); | ||
| } | ||
| .content { | ||
| flex: 1; | ||
| } | ||
| .children { | ||
| min-width: 135px; | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,2 @@ | ||
| export { PreferencesView } from './preferences-view'; | ||
| export { PreferenceRow } from './components/preference-row'; |
3 changes: 3 additions & 0 deletions
3
web/sdk/react/views-new/preferences/preferences-view.module.css
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,3 @@ | ||
| .selectTrigger { | ||
| width: 100%; | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,80 @@ | ||
| import { Flex, Select, Skeleton } from '@raystack/apsara-v1'; | ||
| import { SunIcon, MoonIcon, GearIcon } from '@radix-ui/react-icons'; | ||
| import { BellIcon, BellSlashIcon } from '@raystack/apsara-v1/icons'; | ||
| import { ViewContainer } from '~/react/components/view-container'; | ||
| import { ViewHeader } from '~/react/components/view-header'; | ||
| import { usePreferences } from '~/react/hooks/usePreferences'; | ||
| import { PREFERENCE_OPTIONS } from '~/react/utils/constants'; | ||
| import { PreferenceRow } from './components/preference-row'; | ||
| import { useTheme } from '@raystack/apsara'; | ||
| import styles from './preferences-view.module.css'; | ||
|
|
||
| export function PreferencesView() { | ||
| const { theme, setTheme } = useTheme(); | ||
| const { preferences, isLoading, isFetching, updatePreferences } = | ||
| usePreferences({}); | ||
| console.log(theme); | ||
|
|
||
| const newsletterValue = | ||
| preferences?.[PREFERENCE_OPTIONS.NEWSLETTER]?.value ?? 'false'; | ||
|
|
||
| return ( | ||
| <ViewContainer> | ||
| <ViewHeader | ||
| title="Preferences" | ||
| description="Manage members for this domain." | ||
| /> | ||
| <Flex direction="column"> | ||
| <PreferenceRow | ||
| title="Theme" | ||
| description="Customise your interface color scheme." | ||
| > | ||
| <Select defaultValue={theme} onValueChange={setTheme}> | ||
| <Select.Trigger className={styles.selectTrigger}> | ||
| <Select.Value placeholder="Theme" /> | ||
| </Select.Trigger> | ||
| <Select.Content> | ||
| <Select.Item value="light" leadingIcon={<SunIcon />}> | ||
| Light | ||
| </Select.Item> | ||
| <Select.Item value="dark" leadingIcon={<MoonIcon />}> | ||
| Dark | ||
| </Select.Item> | ||
| <Select.Item value="system" leadingIcon={<GearIcon />}> | ||
| System | ||
| </Select.Item> | ||
| </Select.Content> | ||
| </Select> | ||
| </PreferenceRow> | ||
|
|
||
| <PreferenceRow | ||
| title="Updates, News & Events" | ||
| description="Stay informed on new features, improvements, and key updates." | ||
| isLoading={isFetching} | ||
| > | ||
| <Select | ||
| defaultValue={newsletterValue} | ||
| onValueChange={value => { | ||
| updatePreferences([ | ||
| { name: PREFERENCE_OPTIONS.NEWSLETTER, value } | ||
| ]); | ||
| }} | ||
| disabled={isLoading} | ||
| > | ||
| <Select.Trigger className={styles.selectTrigger}> | ||
| <Select.Value placeholder="Newsletter" /> | ||
| </Select.Trigger> | ||
| <Select.Content> | ||
| <Select.Item value="true" leadingIcon={<BellIcon />}> | ||
| Subscribed | ||
| </Select.Item> | ||
| <Select.Item value="false" leadingIcon={<BellSlashIcon />}> | ||
| Unsubscribed | ||
| </Select.Item> | ||
| </Select.Content> | ||
| </Select> | ||
| </PreferenceRow> | ||
| </Flex> | ||
| </ViewContainer> | ||
| ); | ||
| } |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.