Skip to content

chore(docs): use static values in demos #11769

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 7 commits into from
May 16, 2025

Conversation

Mash707
Copy link
Contributor

@Mash707 Mash707 commented Apr 20, 2025

Closes #11768

@patternfly-build
Copy link
Contributor

patternfly-build commented Apr 20, 2025

@Mash707
Copy link
Contributor Author

Mash707 commented Apr 20, 2025

/patterns/right-to-left/react-demos/paginated-table should I create a sampleData.tsx for this similar to other demos?

Copy link
Contributor

@thatblindgeye thatblindgeye left a comment

Choose a reason for hiding this comment

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

We should make a similar update to the TimestampBasicFormats example file

@thatblindgeye
Copy link
Contributor

@Mash707 for now we could just update those random values in the PaginatedTable file itself

@Mash707
Copy link
Contributor Author

Mash707 commented Apr 21, 2025

@Mash707 for now we could just update those random values in the PaginatedTable file itself

@thatblindgeye There are 25 entries for this example https://www.patternfly.org/patterns/right-to-left/react-demos/paginated-table/, this would make the source code pretty big with unnecessary information. Let me know what you think

@Mash707 Mash707 force-pushed the docs-use-static-data-demos branch from 45b61dd to a511304 Compare April 21, 2025 18:10
@thatblindgeye
Copy link
Contributor

@Mash707 Ah yeah fair, may not hurt to have a separate file for that data then

@Mash707 Mash707 force-pushed the docs-use-static-data-demos branch from a511304 to 3020895 Compare May 3, 2025 23:40
@Mash707
Copy link
Contributor Author

Mash707 commented May 3, 2025

/patterns/right-to-left/react-demos/paginated-table should I create a sampleData.tsx for this similar to other demos?

@thatblindgeye regarding this example I have few things to clarify:

  • I have added a sampleData2.tsx file in the demos folder because only then it is getting build in the dist folder so that I can import it into RTL.md file.
  • I am still trying to figure out how can we handle row translations with static values. Could you recommend an approach that I can work upon to make translations work? Previously every time the translation was switched new rows were created with the new transation.
    useEffect(() => {
    const newRows = createRows();
    setManagedRows(newRows);
    setPaginatedRows(newRows.slice((page - 1) * perPage, page * perPage));
    }, [translation]);

@nicolethoen nicolethoen requested a review from thatblindgeye May 15, 2025 14:49
@thatblindgeye
Copy link
Contributor

@Mash707 one idea could be instead of hard coding the data values in that new sampleData2 file, setting the values of each row's data to the keys of the translation file. So a row's data structure in sampleData2 could look like:

// Pretend this is dataItemOne
{
    status: 'running',
    location: 'raleigh',
    lastModified: 'oneHr'
  }

Then in the demo file itself, we would map over this data structure ^ to get the actual values we want (so something like translation.table.rows.status[dataItemOne.status] would get us the correct status from the appropriate translation structure), including adding the name and url properties based on the index (+ 1) of the current item -- the name property would also just need to reference the node property coming from translation.table.rows.

@Mash707
Copy link
Contributor Author

Mash707 commented May 15, 2025

@thatblindgeye great idea! its seems to work pushing the changes. Let me know what you think.

@Mash707 Mash707 force-pushed the docs-use-static-data-demos branch from 3020895 to c8b132e Compare May 15, 2025 18:06
@Mash707
Copy link
Contributor Author

Mash707 commented May 15, 2025

I have made changes to PaginatedTable.tsx but PaginatedTable.jsx also exists. Should I make similar changes in it too?

Copy link
Contributor

@thatblindgeye thatblindgeye left a comment

Choose a reason for hiding this comment

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

Non-blocking nit below, I'll leave it up to you if you think it's worth changing or keeping as-is.

Can we also just rename the new data file to sampleDataRTL? Just to make it a little clearer its intent.

For the JSX file for this demo, we should be fine to just remove it. I'm assuming when it was converted to TS in #10164 we just forgot to remove the old JSX file.

@Mash707 Mash707 force-pushed the docs-use-static-data-demos branch from c8b132e to 2e0e252 Compare May 16, 2025 17:57
@Mash707 Mash707 requested a review from thatblindgeye May 16, 2025 19:12
@thatblindgeye thatblindgeye merged commit 1b3d58d into patternfly:main May 16, 2025
13 checks passed
@patternfly-build
Copy link
Contributor

Your changes have been released in:

Thanks for your contribution! 🎉

@Mash707 Mash707 deleted the docs-use-static-data-demos branch May 20, 2025 21:02
mattnolting pushed a commit to mattnolting/patternfly-react that referenced this pull request Jun 4, 2025
* chore(docs): use static values in demos

* updated time stamp basic format example

* added static values for RTL demo

* added static values for RTL demo

* removed url and deleted paginatedTable.jsx

* updated import statement

* updated import statement
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Misc docs - demos should not use randomly generated data
4 participants