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

Migrate ActionCard.tsx to tailwind #14244

Open
wants to merge 4 commits into
base: dev
Choose a base branch
from

Conversation

yun-chiao
Copy link
Contributor

@yun-chiao yun-chiao commented Oct 25, 2024

Description

  • Wrapped the ActionCard inside CentralActionCard in eth.tsx with a Box to ensure parameters like sx are correctly passed down.
  • Migrated className to Tailwind CSS.
  • Replaced all components and types from @chakra-ui/react.

Note

I did not replace useColorModeValue with the useColorModeValue from @/hooks/useColorModeValue because I encountered some strange issues.

For example:

const descriptionColor = useColorModeValue(
  "lightmode",
  "darkmode"
)

When using descriptionColor as a className:

<p className={`${descriptionColor}`}></p>

On the first render, it always gets "darkmode" in className, but when I console.log(descriptionColor), it consistently returns "lightmode" from the first print.

After doing some debugging inside @/hooks/useColorModeValue, I suspect it is related to the theme being null on the initial render, which causes the conditional check to fail and return "darkmode". However, I am unsure why console.log(descriptionColor) which would be "lightmode" and the actual descriptionColor applied to the CSS behave inconsistently.

Snapshoot

localhost


截圖 2024-10-26 上午3 10 05
截圖 2024-10-26 上午3 10 23

https://ethereum.org/

截圖 2024-10-26 上午3 10 58 截圖 2024-10-26 上午3 10 53

Related Issue

#13946

Copy link

netlify bot commented Oct 25, 2024

Deploy Preview for ethereumorg ready!

Name Link
🔨 Latest commit b0faf55
🔍 Latest deploy log https://app.netlify.com/sites/ethereumorg/deploys/67306695e4e35f000813e186
😎 Deploy Preview https://deploy-preview-14244--ethereumorg.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.
Lighthouse
Lighthouse
7 paths audited
Performance: 44 (🔴 down 12 from production)
Accessibility: 92 (no change from production)
Best Practices: 89 (🔴 down 9 from production)
SEO: 99 (no change from production)
PWA: -
View the detailed breakdown and full score reports

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

@isabelladebrito isabelladebrito added the hacktoberfest Track hacktoberfest activity label Oct 28, 2024
@pettinarip pettinarip mentioned this pull request Oct 28, 2024
65 tasks
Copy link
Member

@pettinarip pettinarip left a comment

Choose a reason for hiding this comment

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

@yun-chiao thanks for the PR. Left a reply about useColorModeValue. LMK what do you think

src/components/ActionCard.tsx Outdated Show resolved Hide resolved
src/components/ActionCard.tsx Outdated Show resolved Hide resolved
src/components/ActionCard.tsx Outdated Show resolved Hide resolved
src/pages/eth.tsx Show resolved Hide resolved
@yun-chiao
Copy link
Contributor Author

yun-chiao commented Nov 10, 2024

useColorModeValue

Hi @pettinarip ,

I've updated this PR, and here’s some information about the issue with useColorModeValue. Thanks!

Description

I found an example that has been merged and is using useColorModeValue: <EthVideo>. When I'm in light mode and reload the page, the first render applies the dark mode setting instead of the light mode, as shown in the attached image. However, it behaves correctly when switching between modes.

Debugging

If I add the following to useColorModeValue:

if (resolvedTheme == null) {
  return "null_theme";
}

I then get "null_theme" in src={src}, but if I console.log related information in , it returns the light mode variable as expected, e.g., "/images/ethereum-hero-light.mp4", with no trace of "null_theme" in the console. I find this behavior odd, as the displayed result in HTML and CSS differs from the variable output.

Thank you!

Attachment

Snapshoot for <EthVideo>.
It should get the src = "/images/ethereum-hero-light.mp4" in the light mode.
截圖 2024-11-10 下午4 10 38

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
hacktoberfest Track hacktoberfest activity
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants