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

Steps: Cannot style active step in unstyled mode #6870

Closed
girardinsamuel opened this issue Jul 11, 2024 · 3 comments · Fixed by #7101
Closed

Steps: Cannot style active step in unstyled mode #6870

girardinsamuel opened this issue Jul 11, 2024 · 3 comments · Fixed by #7101
Assignees
Labels
Component: Unstyled Issue related to unstyled/passthrough attributes
Milestone

Comments

@girardinsamuel
Copy link

girardinsamuel commented Jul 11, 2024

Describe the bug

Hi,

I am using Steps component in unstyled mode and I am trying to define styles. I managed to style the component, but not to style the active step (like putting a different background color).

Here is the code for the theme :

const Tailwind = {
    steps: {
            // ... other styles
            step: ({ props, state }) => ({
                className: clsx(
                    'flex items-center justify-center',
                    'text-zinc-950 dark:text-white border border-zinc-950/10 dark:border-white/10 w-[2rem] h-[2rem] leading-2rem text-sm z-10 rounded-full',
                    {
                        'bg-gray-500': props.activeIndex !== ?,
// here I don't know what I need to write to check if active, I don't have access to context.index ?
                        'bg-green-500': props.activeIndex == ?,
                    }
                ),
            }),
}

and the basic component usage :

import { useState } from 'react'
import { Steps } from 'primereact/steps'

export default function MyComponent() {
    const [activeIndex, setActiveIndex] = useState(0)
    const items = [
        {
            label: 'Personal Info'
        },
        {
            label: 'Reservation'
        },
        {
            label: 'Review'
        }
    ];

    return (
            <Steps model={items} activeIndex={activeIndex} />
    )
}
        

It seems that in steps theme we have access to props and state but I cannot manage to get a conditional expression to check if step is active or not...

In the demo, the active style exists but I don't know how to create it.
What is the solution 🙏 ?
Thank you in advance,

Reproducer

No response

PrimeReact version

10.7.0

React version

18.x

Language

TypeScript

Build / Runtime

Vite

Browser(s)

No response

Steps to reproduce the behavior

No response

Expected behavior

No response

@girardinsamuel girardinsamuel added the Status: Needs Triage Issue will be reviewed by Core Team and a relevant label will be added as soon as possible label Jul 11, 2024
@girardinsamuel girardinsamuel changed the title Stepps: Cannot style active step in unstyled mode Steps: Cannot style active step in unstyled mode Jul 11, 2024
@melloware melloware added Component: Unstyled Issue related to unstyled/passthrough attributes and removed Status: Needs Triage Issue will be reviewed by Core Team and a relevant label will be added as soon as possible labels Jul 11, 2024
@gcko
Copy link
Contributor

gcko commented Aug 21, 2024

@melloware The code for Steps does not make a distinction between an whether a step is currently active or not.

Functionally, it should be exactly the same as how it is handled in TabView.js for each tab.

Specifically, the following lines should be adapted for use in the Steps component: https://github.com/primefaces/primereact/blob/master/components/lib/tabview/TabView.js#L51-L83 and https://github.com/primefaces/primereact/blob/master/components/lib/tabview/TabView.js#L107-L126

@melloware
Copy link
Member

@gcko i agree. Do you want to take this one?

@gcko
Copy link
Contributor

gcko commented Aug 22, 2024

@melloware sure I can take a look at implementing the functionality

gcko added a commit to gcko/primereact that referenced this issue Sep 2, 2024
…ed on parent and context

- Pull code from TabView.js and ensure it works correctly under steps
- Put in some initial styling for `step` and `label`
- TODO add typing for parent and context
gcko added a commit to gcko/primereact that referenced this issue Sep 2, 2024
Do not implement child props at the moment
melloware pushed a commit that referenced this issue Sep 2, 2024
* feat: #6870 Ensure steps can be programmatically styled based on parent and context

- Pull code from TabView.js and ensure it works correctly under steps
- Put in some initial styling for `step` and `label`
- TODO add typing for parent and context

* feat: #6870 Add typing to steps.d.ts

Do not implement child props at the moment
@melloware melloware added this to the 10.8.3 milestone Sep 2, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Component: Unstyled Issue related to unstyled/passthrough attributes
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants