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

Staking steps overview - modal component #102

Merged
merged 3 commits into from
Jan 4, 2024
Merged

Conversation

kkosiorowska
Copy link
Contributor

Closes #96

This PR adds an overview of the staking steps. This is a simple component that displays the steps a user needs to go through to make a stake transaction.

UI

Screenshot 2023-12-29 at 12 15 39

@kkosiorowska kkosiorowska self-assigned this Dec 29, 2023
return <TextMd color="grey.500">{children}</TextMd>
}

const STEPS = [
Copy link
Contributor

Choose a reason for hiding this comment

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

Let's move these steps to a standalone file.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I wonder if it makes sense for sure. This component is responsible for overview so I would look for the declared steps here. So in that case, where do you think such a file should be located?

Copy link
Contributor

Choose a reason for hiding this comment

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

Generally, I like organization patterns of keeping one function per file (excluding: utils/helpers) - this makes the code more readable. Take a look at the components Title/Description in this file - used only in the Steps, but the default exported function is Overview, which doesn't use Title/Description directly. In my opinion, we should keep small portions of codes(directly related to the main function) as simple as possible.
We should move STEPS also with helpers functions (Title/Description) to a standalone file, eg:
/src/components/Modals/Staking/Overview.utils.tsx or /src/components/Modals/Staking/utils/stepsOverview.tsx

@r-czajkowski What do you think?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

TBH, I'm not a fan of creating separate files for small pieces of logic(functions dedicated only to this component or consts). Often then it gets messy and it's difficult to find something if we have a lot of files. I think that in most of the thesis projects we used this pattern.

@r-czajkowski Please let us know what you think. You have much more experience here.

Copy link
Contributor

Choose a reason for hiding this comment

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

Small pieces of logic are better because every file in this case has logic related to its needs - it doesn't make a mess in the code. IDE is responsible for not having to look for those files manually.

Copy link
Contributor

Choose a reason for hiding this comment

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

I see advantages in both approaches 😆. But in this case I would do the same tbh, because as you said Piotr, the steps have no logic - we just define a variable that is used in the overview component. I would extract them(steps, Title and Description) to a separate file if they were reusable components in the Staking domain eg:

src/
└── components/
    └── Modals/
        └── staking/
            ├── components/
            │   └── StakingSteps.tsx
            ├── index.tsx
            ├── StakeForm.tsx
            └── Overview.tsx
function Title({ children }: { children: React.ReactNode }) {
  return <TextLg fontWeight="bold">{children}</TextLg>
}

function Description({ children }: { children: React.ReactNode }) {
  return <TextMd color="grey.500">{children}</TextMd>
}

const STEPS = [
  {
    id: "sign-message",
    title: <Title>Sign message</Title>,
    description: (
      <Description>
        You will sign a gas-free Ethereum message to indicate the address where
        you&apos;d like to get your stBTC liquid staking token.
      </Description>
    ),
  },
  {
    id: "deposit-btc",
    title: <Title>Deposit BTC</Title>,
    description: (
      <Description>
        You will make a Bitcoin transaction to deposit and stake your BTC.
      </Description>
    ),
  },
]

export default function StakingSteps() {
  return (
    
        <StepperBase
          index={-1}
          height={64}
          size="sm"
          orientation="vertical"
          complete={<StepNumber />}
          steps={STEPS}
        />
     
  )
}

or would put them in a src/components/shared dir if they were used in other places as well.

Copy link
Contributor

@ioay ioay Jan 3, 2024

Choose a reason for hiding this comment

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

@r-czajkowski I like your idea!
Small improvements: Instead of nesting the components folders, we can pull the Overview.tsx and StakingSteps.tsx into the Overview folder, eg:

src/
└── components/
    └── Modals/
        └── staking/
            ├── Overview/
            │   └── Overview.tsx
            │   └── StakingSteps.tsx
            ├── index.tsx
            └── StakeForm.tsx

Copy link
Contributor

Choose a reason for hiding this comment

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

@r-czajkowski I like your idea! Small improvements: Instead of nesting the components folders, we can pull the Overview.tsx and StakingSteps.tsx into the Overview folder, eg:

src/
└── components/
    └── Modals/
        └── staking/
            ├── Overview/
            │   └── Overview.tsx
            │   └── StakingSteps.tsx
            ├── index.tsx
            └── StakeForm.tsx

One more improvement: since we are in the Overview domain I would rename to index.tsx.

src/
└── components/
    └── Modals/
        └── staking/
            ├── Overview/
            │   └── index.tsx
            │   └── StakingSteps.tsx
            ├── index.tsx
            └── StakeForm.tsx

Copy link
Contributor Author

Choose a reason for hiding this comment

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

We can do it this way as @r-czajkowski suggested. This logic will have to be updated anyway in a future PR on staking steps. Probably then we will want to use the structure proposed earlier:

src/
└── components/
    └── Modals/
        └── staking/
            ├── components/
            │   └── StakingSteps.tsx
            ├── index.tsx
            ├── StakeForm.tsx
            └── Overview.tsx

Or something else will be determined in the next step.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@kkosiorowska kkosiorowska requested a review from ioay January 3, 2024 07:28
Copy link
Contributor

@ioay ioay left a comment

Choose a reason for hiding this comment

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

LGTM 🚀

@kkosiorowska kkosiorowska merged commit a040b05 into main Jan 4, 2024
11 checks passed
@kkosiorowska kkosiorowska deleted the staking-overview branch January 4, 2024 09:14
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Staking steps overview
3 participants