Giter VIP home page Giter VIP logo

ud-factory's Introduction

UniversalDashboard.Factory

Tools for generating custom components and frameworks for PowerShell Universal.

โš  This tool is experimental.

Requires

Installation

Install-Module UniversalDashboard.Factory

Frameworks

Generating a Framework

The following example creates a new framework based on Ant Design.

Export-UDFramework -Package 'antd' -Name 'AntDesign' -AdditionalImports 'antd/dist/antd.css'

The following example creates a new framework based on React-Bootsrap.

Export-UDFramework -Package react-bootstrap -AdditionalPackages bootstrap@4.6.0 -Name bootstrap -AdditionalImports 'bootstrap/dist/css/bootstrap.min.css'

Installing a Framework

Copy the output from Export-UDFramework to the `C:\ProgramData\PowerShellUniversal\UniversalDashboard\Frameworks

Using a Framework

The framework generated by this tool does not create custom cmdlets but relies on a single New-UDComponent cmdlet to create any component in the library.

New-UDComponent -Type 'Layout' -Content {
    New-UDComponent -Type 'Layout.Header' -Content {
        New-UDComponent -Type "Menu" -Properties @{
            mode = "horizontal"
            theme = 'dark'
            onClick = [Endpoint]{ Set-UDElement -Id 'button' -Content { "Cool" } }
        } -Content {
            New-UDComponent -Type "Menu.Item" -Content { "nav1" }
            New-UDComponent -Type "Menu.Item" -Content { "nav2" }
            New-UDComponent -Type "Menu.Item" -Content { "nav3" }
        }
    }
    New-UDComponent -Type 'Layout.Content' -Content {
        New-UDComponent -Type 'Button' -Properties @{
            type = 'primary'
        } -Content {
            "Hey123"
        } -Id 'button'

        New-UDComponent -Type 'Timeline' -Content {
            New-UDComponent -Type 'Timeline.Item' -Content { 'Create a services site 2015-09-01' }
            New-UDComponent -Type 'Timeline.Item' -Content { 'Solve initial network problems 2015-09-01' }
            New-UDComponent -Type 'Timeline.Item' -Content { 'Solve initial network problems 2015-09-01' }
            New-UDComponent -Type 'Timeline.Item' -Content { 'Network problems being solved 2015-09-01' }
        }
        New-UDComponent -Type 'Alert' -Properties @{
            message = 'Success Text'
            type = 'success'
        }
    }
}

Bootstrap

New-UDComponent -Type 'Button' -Content {
    "Hello"
} -Properties @{
    variant = 'primary'
}

Benefits

  • Generate a new framework with a single command
  • Automatically adds support for things like Set-UDElement

Limitations

There are many limitations to this tool.

  • No custom functions for components
  • No packaging optimization so large bundle sizes
  • Event handlers are currently not working
  • State management hasn't be worked out.
  • Modals and toasts currently don't work

Convert HTML to UDComponents

Auto-generated frameworks use New-UDComponent to create React components. You can use ConvertTo-UDComponent to use examples from framework websites and convert them into Universal Dashboard scripts.

'<Alert variant="success">
  <Alert.Heading>Hey, nice to see you</Alert.Heading>
  <p>
    Aww yeah, you successfully read this important alert message. This example
    text is going to run a bit longer so that you can see how spacing within an
    alert works with this kind of content.
  </p>
  <hr />
  <p className="mb-0">
    Whenever you need to, be sure to use margin utilities to keep things nice
    and tidy.
  </p>
</Alert>' | ConvertTo-UDComponent

The resulting script would look like this.

New-UDComponent -Type 'Alert' -Properties @{
        variant= 'success'
} -Content {
        New-UDComponent -Type 'Alert.Heading' -Content {
                "Hey, nice to see you"
        }
        New-UDComponent -Type 'p' -Content {
                "
    Aww yeah, you successfully read this important alert message. This example
    text is going to run a bit longer so that you can see how spacing within an
    alert works with this kind of content.
  "
        }
        New-UDComponent -Type 'hr'
        New-UDComponent -Type 'p' -Properties @{
                className= 'mb-0'
        } -Content {
                "
    Whenever you need to, be sure to use margin utilities to keep things nice
    and tidy.
  "
        }
}

If you specify the -Dense parameter, you can also generate script that uses aliases and position parameters.

c  'Alert'  @{ variant= 'success'; }  {
        c  'Alert.Heading'  {
                "Hey, nice to see you"  }
        c  'p'  {
                "
    Aww yeah, you successfully read this important alert message. This example
    text is going to run a bit longer so that you can see how spacing within an
    alert works with this kind of content.
  "     }
        c  'hr'
        c  'p'  @{ className= 'mb-0';   }  {
                "
    Whenever you need to, be sure to use margin utilities to keep things nice
    and tidy.
  "     }
}

ud-factory's People

Contributors

adamdriscoll avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.