@@ -35,3 +35,47 @@ Currently this is just proof of concept. I will likely add to this over time.
35
35
36
36
# Examples
37
37
See ` examples ` directory for examples of using this.
38
+
39
+ One of the fundamental aspects of this library is the ability to preload your own custom styles from a dictionary, like so:
40
+ ``` python
41
+ from rich.console import Console
42
+ from src.string_builder import RichStyles
43
+
44
+ console = Console()
45
+
46
+ my_styles = {
47
+ " alert" : " blink yellow" ,
48
+ " headers" : {
49
+ " main" : " bold" ,
50
+ " sub" : " #4196D6"
51
+ }
52
+ }
53
+ rs = RichStyles(my_styles)
54
+ console.print(rs.custom.alert(" WARNING!" )) # '[blink yellow]WARNING![/blink yellow]'
55
+ ```
56
+
57
+ Though you are able to combine these styles ad-hoc:
58
+
59
+ ``` python
60
+ bright_blue = rs.Styles.bright + rs.Colors.blue
61
+ console.print(bright_blue(" Coldkey" )) # '[bright blue]Coldkey[/bright blue]'
62
+ ```
63
+
64
+ Say you have a complicated custom style, and you wish to only remove an element or two and reuse it:
65
+ ``` python
66
+ my_styles = {
67
+ " foo" : " blink bright yellow"
68
+ }
69
+ rs = RichStyles(my_styles)
70
+ console.print((rs.custom.foo - " blink" )(" Hello!" )) # '[bright yellow]Hello![/bright yellow]'
71
+ # or define a new type:
72
+ bar = rs.custom.foo - " blink"
73
+ console.print(bar(" Hello!" )) # '[bright yellow]Hello![/bright yellow]'
74
+ ```
75
+
76
+
77
+ # Who is this for?
78
+ I am personally colourblind. It's nice to have someone who is not colourblind define a colour palette, and I simply
79
+ build from this. While colourblind people are not the only intended users, I think it will help them (us) substantially
80
+ in terms of readability of the styles.
81
+ It's also very helpful for keeping easier track of your styles and reusability.
0 commit comments