taiga-family / taiga-ui

Angular UI Kit and components library for awesome people
https://taiga-ui.dev
Apache License 2.0
3.21k stars 439 forks source link

πŸš€ - `Demo` add ability to declaratively control examples order #9113

Closed mdlufy closed 1 week ago

mdlufy commented 1 week ago

Description

<ng-template pageTab>
        <tui-doc-example
            *ngFor="let example of examples; let index = index"
            [component]="index + 1 | tuiComponent"
            [content]="index + 1 | tuiExample
            [heading]="example"
            [id]="example | tuiKebab"
        />
    </ng-template>

Problem: When adding new examples, a folder with the index n + 1 is created. There is no way to insert an example in the middle, between the other examples, without swapping and renaming the new example folder with some other one examples folder.

For example, the 13th example are being created and you need to make it 8th in the list. The only way to do this now is to swap places with the current 8th example. But the example that was in 8th place does not belong in last. Now you need to change it again with someone before and so on all the time.

Such manipulations are inconvenient and end up with a dirty github changes in PR and it becomes difficult to review. Such PR, for example, #9114

Proposed solution: Add the ability to declaratively set the order of examples in the main file. It can be implemented in the form of creating a key for each example and associating this key with an array in the main example index.ts file to control the order

protected readonly examplesOrder = [
        SecondExampleKey,
        FirstExampleKey,
        ...,
    ];
mdlufy commented 1 week ago

Not relevant yet