Skip to content

Add a way to have placeholder or dummy data that are only shown in the preview.  #6113

@ogoffart

Description

@ogoffart

When developing a component, it is useful to add dummy data for models and things that are not part of the application but would be useful to have when previewing.

Suggestions:

component Foo {
   // Load all 'in' properties from a json file  (relative to this file)
   // (only for preview)
   @dummy-data("./file.json")

   // the 'dummy' built-in function is like an identity function in preview mode, 
   // but is deleted and the default value is used in production.
   in property [{name: string, age: int}] model: dummy([{name: "John", age: 85}, {name: "Jane", age: 16}]);
}

The preview could offer an UI to edit these.

The slint-viewer can also load these or have an argument to remove them. (it can already load json with --load-data but that'd be orthogonal)

Exact naming of these macros/functions can be discussed.

Metadata

Metadata

Assignees

No one assigned

    Labels

    a:language-slintCompiler for the .slint language (mO,bF)rfcRequest for comments: proposals for changes

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions