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

refactor: fix name and state inconsistency in <ThemedLayoutV2>. #4404

Merged
merged 22 commits into from
May 30, 2023

Conversation

salihozdemir
Copy link
Contributor

@salihozdemir salihozdemir commented May 26, 2023

useSiderVisible is deprecated, instead we created a new hook useSiderState for it. useSiderState similar to useSiderVisible but it returns more meaningful state names. However, useSiderVisible is still available for backward compatibility.

Updated Sider and HamburgerMenu components using useSiderState.

import { useSiderState } from '@refinedev/antd'; // or @refinedev/chakra-ui, @refinedev/mui, @refinedev/mantine
const {
    siderCollapsed,
    setSiderCollapsed,
    mobileSiderOpen,
    setMobileSiderOpen,
} = useSiderState();

Test plan (required)

Tests not affected.

Self Check before Merge

Please check all items below before review.

  • Corresponding issues are created/updated or not needed
  • Docs are updated/provided or not needed
  • Examples are updated/provided or not needed
  • TypeScript definitions are updated/provided or not needed
  • Tests are updated/provided or not needed
  • Changesets are provided or not needed

@changeset-bot
Copy link

changeset-bot bot commented May 26, 2023

🦋 Changeset detected

Latest commit: d4699ed

The changes in this PR will be included in the next version bump.

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@netlify
Copy link

netlify bot commented May 26, 2023

Deploy Preview for lighthearted-pastelito-e86ad1 ready!

Name Link
🔨 Latest commit d4699ed
🔍 Latest deploy log https://app.netlify.com/sites/lighthearted-pastelito-e86ad1/deploys/647618657da6b3000813f29d
😎 Deploy Preview https://deploy-preview-4404--lighthearted-pastelito-e86ad1.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify site settings.

@netlify
Copy link

netlify bot commented May 26, 2023

Deploy Preview for refine-doc-live-previews ready!

Name Link
🔨 Latest commit d4699ed
🔍 Latest deploy log https://app.netlify.com/sites/refine-doc-live-previews/deploys/647618656d2a940008cb68a6
😎 Deploy Preview https://deploy-preview-4404--refine-doc-live-previews.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify site settings.

@netlify
Copy link

netlify bot commented May 26, 2023

Deploy Preview for aquamarine-panda-e208bf ready!

Name Link
🔨 Latest commit d4699ed
🔍 Latest deploy log https://app.netlify.com/sites/aquamarine-panda-e208bf/deploys/647618651941fb0008e5a558
😎 Deploy Preview https://deploy-preview-4404--aquamarine-panda-e208bf.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify site settings.

@refine-bot refine-bot temporarily deployed to deploy-preview-mui-4404 May 26, 2023 13:46 Inactive
@netlify
Copy link

netlify bot commented May 26, 2023

Deploy Preview for imaginative-sundae-1fd394 ready!

Name Link
🔨 Latest commit d4699ed
🔍 Latest deploy log https://app.netlify.com/sites/imaginative-sundae-1fd394/deploys/647618651941fb0008e5a55d
😎 Deploy Preview https://deploy-preview-4404--imaginative-sundae-1fd394.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify site settings.

@netlify
Copy link

netlify bot commented May 26, 2023

Deploy Preview for stupendous-taffy-33f80c ready!

Name Link
🔨 Latest commit d4699ed
🔍 Latest deploy log https://app.netlify.com/sites/stupendous-taffy-33f80c/deploys/64761865852f710008223cdb
😎 Deploy Preview https://deploy-preview-4404--stupendous-taffy-33f80c.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify site settings.

@refine-bot refine-bot temporarily deployed to deploy-preview-antd-4404 May 26, 2023 13:49 Inactive
@nx-cloud
Copy link

nx-cloud bot commented May 26, 2023

☁️ Nx Cloud Report

CI is running/has finished running commands for commit d4699ed. As they complete they will appear below. Click to see the status, the terminal output, and the build insights.

📂 See all runs for this branch


🟥 Failed Commands
lerna run cypress:run --scope base-material-ui
lerna run cypress:run --scope base-mantine
lerna run cypress:run --scope table-antd-use-table
lerna run cypress:run --scope base-chakra-ui
lerna run build --include-dependencies --scope @refinedev/core --no-bail --scope=upload-mantine-multipart --scope=upload-material-ui-base64 --scope=upload-material-ui-multipart --scope=upload-mui-base64 --scope=upload-mui-multipart --scope=use-infinite-list --scope=use-modal-antd --scope=use-simple-list-antd --scope=vite --scope=web3 --scope=with-c...
✅ Successfully ran 41 targets

Sent with 💌 from NxCloud.

@refine-bot refine-bot temporarily deployed to deploy-preview-website-4404 May 26, 2023 14:03 Inactive
@refine-bot refine-bot temporarily deployed to deploy-preview-mui-4404 May 27, 2023 11:58 Inactive
@refine-bot refine-bot temporarily deployed to deploy-preview-antd-4404 May 27, 2023 11:59 Inactive
@refine-bot refine-bot temporarily deployed to deploy-preview-website-4404 May 27, 2023 12:20 Inactive
@refine-bot refine-bot temporarily deployed to deploy-preview-mui-4404 May 27, 2023 12:49 Inactive
@refine-bot refine-bot temporarily deployed to deploy-preview-antd-4404 May 27, 2023 12:50 Inactive
@refine-bot refine-bot temporarily deployed to deploy-preview-website-4404 May 27, 2023 13:07 Inactive
@refine-bot refine-bot temporarily deployed to deploy-preview-mui-4404 May 29, 2023 06:49 Inactive
@refine-bot refine-bot temporarily deployed to deploy-preview-antd-4404 May 29, 2023 06:54 Inactive
@refine-bot refine-bot temporarily deployed to deploy-preview-website-4404 May 29, 2023 07:10 Inactive

export type UseSiderStateType = IThemedLayoutContext;

export const useSiderState = (): UseSiderStateType => {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

maybe we can change useSiderState name to useSider or useThemedSider.
with that name convention, we can add more features to this hook in the future.

@aliemir @BatuhanW @yildirayunlu what do you think?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

it's a good idea

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

useSiderState has more predictable than useSider or useThemedSider. I mean, the users can better know what the useSiderState hook does.

If we want to change the name to add something in the future we can do something more generic like useLayoutContext.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Agree with @salihozdemir, useSiderState is more descriptive than useSider or useThemedSider which looks more like useMenu or useBreadcrumb and users might confuse them with useMenu.

We can call it useThemedLayoutContext, which matches with the name of the context as well (ThemedLayoutContext).

@omeraplak omeraplak requested a review from aliemir May 30, 2023 07:29
@aliemir
Copy link
Member

aliemir commented May 30, 2023

General

  • We've resolved the inconsistency issues throughout the UI packages
  • State values are renamed properly and usable through the new hook
  • Old values are deprecated but still functioning
  • Implemented the useThemedLayoutContext hook.

@refinedev/antd

  • Context is updated and uses the new names for the states.
  • Old values are deprecated but aligned with the new state values.
  • Users with swizzled siders can keep using without breaking changes + no need to update the variables if they don't want to.
  • Users with swizzled layout can keep using the old context provider component without breaking changes or any need for an update. This means the initialSiderCollapsed still works as expected.
  • Users can use new values and adjust their components to use them with no issues.
  • We've updated the examples with the new hook and the new values.
  • The old hooks is still working but deprecated.

@refinedev/mui

  • Context is updated and uses the new names for the states.
  • Old values are deprecated but aligned with the new state values.
  • Users with swizzled siders can keep using without breaking changes + no need to update the variables if they don't want to.
  • Users with swizzled layout can keep using the old context provider component without breaking changes or any need for an update. This means the initialSiderCollapsed still works as expected.
  • Users can use new values and adjust their components to use them with no issues.
  • We've updated the examples with the new hook and the new values.
  • The old hooks is still working but deprecated.

@refinedev/chakra-ui

  • Context is updated and uses the new names for the states.
  • Old values are deprecated but aligned with the new state values.
  • Users with swizzled siders can keep using without breaking changes + no need to update the variables if they don't want to.
  • Users with swizzled layout can keep using the old context provider component without breaking changes or any need for an update. This means the initialSiderCollapsed still works as expected.
  • Users can use new values and adjust their components to use them with no issues.
  • We've updated the examples with the new hook and the new values.
  • The old hooks is still working but deprecated.

@refinedev/mantine

  • Context is updated and uses the new names for the states.
  • Old values are deprecated but aligned with the new state values.
  • Users with swizzled siders can keep using without breaking changes + no need to update the variables if they don't want to.
  • Users with swizzled layout can keep using the old context provider component without breaking changes or any need for an update. This means the initialSiderCollapsed still works as expected.
  • Users can use new values and adjust their components to use them with no issues.
  • We've updated the examples with the new hook and the new values.
  • The old hooks is still working but deprecated.

@salihozdemir Let's use the above checklist to make sure we're good to go.

@refine-bot refine-bot temporarily deployed to deploy-preview-mui-4404 May 30, 2023 13:00 Inactive
@refine-bot refine-bot temporarily deployed to deploy-preview-antd-4404 May 30, 2023 13:01 Inactive
@refine-bot refine-bot temporarily deployed to deploy-preview-website-4404 May 30, 2023 13:15 Inactive
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

5 participants