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

Add Theme Support #43

Open
iainbrighton opened this issue May 12, 2017 · 5 comments
Open

Add Theme Support #43

iainbrighton opened this issue May 12, 2017 · 5 comments

Comments

@iainbrighton
Copy link
Owner

It would be good to have multiple built-in themes, but more importantly - have the ability for people to create their own themes and have these apply to a document at generation time.

For this to work, the built-in styles would:

  • Need to be expanded to include more than a couple of styles
  • Need to be documented
@jbruett
Copy link
Contributor

jbruett commented Nov 20, 2017

Iain,

I saw this out there and thought I would take a look at it. I wanted to run by you what I was thinking about to get yours and others inputs.

So my basic thought is using psd1 files as the input/storage methods for all styles, including the embedded default. The module would look for the default embedded file, wich would be included by default, as well as any psd1 files in a given path for additional custom styles. The module would load each file in a similar fashion as it does today, adding them to the styles array of a the document object.

The PSD1 file would be a collection of objects that include properties that correspond to each of the possible settings of a style (based on the parameters of the style command). An additional function could be added to create a basic style template file.

Here's an example style file:

@{
    MyCustomStyle = @{
        Name = 'MyCustomStyle'
        Size = 12
        Font = 'Tahoma'
        color = 'red'
        bold = $true
        align = 'center'
        default = $false
    }
    Big = @{
        size = 48
    }
}

As you can see, not every parameter would need to be specified, as the style function will handle that as needed.

In either case, let me know your thoughts.

Thanks,
JB

@jbruett
Copy link
Contributor

jbruett commented Nov 20, 2017

I just realized that Table styles are different. I would imagine that could be handled a couple of ways, either additional files with a specific naming format (not super flexible), a property in the parent node that indicates the file is intended to be a table style file, or maybe a single file with a styles block and a tablestyles block and you simply parse the two blocks as they are intended.

@iainbrighton
Copy link
Owner Author

@jbruett When the PScribo document is created, a PSCustomObject is returned with a Styles and TableStyles properties. It might be easiest to match this format in a .psd1 file and merge it in?

[9] C:\.....\PScribo\Examples [dev ≡]> $example10 = Document -Name 'PScribo Example 10' {
    Table -InputObject (Get-Service)
}
[10] C:\.....\PScribo\Examples [dev ≡]> $example10

Id                : PSCRIBOEXAMPLE10
Type              : PScribo.Document
Name              : PScribo Example 10
Sections          : {@{Id=1C1DD641-A3D2-48E0-AAFC-DE5849FEB304; Name=1c1dd641-a3d2-48e0-aafc-de5849feb304;
                    Type=PScribo.Table; Columns=System.String[]; ColumnWidths=; Rows=System.Collections.ArrayList;
                    List=False; Style=TableDefault; Width=100; Tabs=0}}
Options           : {MarginBottom, MarginLeft, MarginRight, DefaultFont...}
Properties        : {Styles, Tables, TableStyles}
Styles            : {TOC, Heading4, Heading2, Normal...}
TableStyles       : {TableDefault}
DefaultStyle      : Normal
DefaultTableStyle : TableDefault
TOC               : {}

[11] C:\.....\PScribo\Examples [dev ≡]> $example10.Styles

Name                           Value
----                           -----
TOC                            @{Id=TOC; Name=TOC; Font=System.String[]; Size=16; Color=0072af; BackgroundColor=; Bo...
Heading4                       @{Id=Heading4; Name=Heading 4; Font=System.String[]; Size=11; Color=2f5496; Backgroun...
Heading2                       @{Id=Heading2; Name=Heading 2; Font=System.String[]; Size=14; Color=0072af; Backgroun...
Normal                         @{Id=Normal; Name=Normal; Font=System.String[]; Size=11; Color=000000; BackgroundColo...
TableDefaultHeading            @{Id=TableDefaultHeading; Name=TableDefaultHeading; Font=System.String[]; Size=11; Co...
Heading1                       @{Id=Heading1; Name=Heading 1; Font=System.String[]; Size=16; Color=0072af; Backgroun...
Title                          @{Id=Title; Name=Title; Font=System.String[]; Size=28; Color=0072af; BackgroundColor=...
TableDefaultRow                @{Id=TableDefaultRow; Name=TableDefaultRow; Font=System.String[]; Size=11; Color=0000...
Footer                         @{Id=Footer; Name=Footer; Font=System.String[]; Size=8; Color=0072af; BackgroundColor...
Heading6                       @{Id=Heading6; Name=Heading 6; Font=System.String[]; Size=11; Color=1f3763; Backgroun...
TableDefaultAltRow             @{Id=TableDefaultAltRow; Name=TableDefaultAltRow; Font=System.String[]; Size=11; Colo...
Heading5                       @{Id=Heading5; Name=Heading 5; Font=System.String[]; Size=11; Color=2f5496; Backgroun...
Heading3                       @{Id=Heading3; Name=Heading 3; Font=System.String[]; Size=12; Color=0072af; Backgroun...

We will also need to decide whether an applied theme should override any styles defined in the document? My gut feel is probably not.

@jbruett
Copy link
Contributor

jbruett commented Nov 21, 2017

So let me ask you a more theoretical question. What's a theme to you? to me it's just a collection of styles. The default styles that you're using now are basically the default theme in word. Do you envision them as some sort of identifiable object that defines the collection of styles which are then inherently applied?

@iainbrighton
Copy link
Owner Author

Correct the default "theme" is just a copy of the default Word 2013 styles. I envisaged a theme to be a collection of predefined styles in a .psd1 file (that might just happen to match the internal object structure 😉). Here are my thoughts. A theme:

  • Is a collection of styles
    • must include definitions for default styles
    • can include definitions for additional styles
    • can be bundled/merged into the PScribo module
    • custom themes can be defined/stored in a .psd1 file
  • Themes can be applied to Export-Document to format final document(s)
    • bundled themes can be applied/specified by name
    • custom themes can be applied/specified by path
  • In-line styles, e.g. the Style keyword should override theme styles
    • Maybe this behaviour could be controlled by a switch parameter?

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

No branches or pull requests

2 participants