baserow.color

  1import enum
  2import random
  3from typing import Optional
  4
  5from typing_extensions import Self
  6
  7
  8class Color(str, enum.Enum):
  9    """The colors defined and provided by Baserow."""
 10
 11    DARK_BLUE = "dark-blue"
 12    """Hex: #acc8f8"""
 13    DARK_GREEN = "dark-green"
 14    """Hex: #a0eeba"""
 15    DARK_CYAN = "dark-cyan"
 16    """Hex: #70e0ef"""
 17    DARK_YELLOW = "dark-yellow"
 18    """Hex: #ffdd8f"""
 19    DARK_ORANGE = "dark-orange"
 20    """Hex: #ffe9b4"""
 21    DARK_RED = "dark-red"
 22    """Hex: #ffbdb4"""
 23    DARK_BROWN = "dark-brown"
 24    """Hex: #f5c098"""
 25    DARK_PURPLE = "dark-purple"
 26    """Hex: #cf96f2"""
 27    DARK_PINK = "dark-pink"
 28    """Hex: #f285d9"""
 29    DARK_GRAY = "dark-gray"
 30    """Hex: #b5b5b7"""
 31    LIGHT_BLUE = "light-blue"
 32    """Hex: #f0f4fc"""
 33    LIGHT_GREEN = "light-green"
 34    """Hex: #ecfcf1"""
 35    LIGHT_CYAN = "light-cyan"
 36    """Hex: #cff5fa"""
 37    LIGHT_YELLOW = "light-yellow"
 38    """Hex: #fffbf0"""
 39    LIGHT_ORANGE = "light-orange"
 40    """Hex: #fffbf0"""
 41    LIGHT_RED = "light-red"
 42    """Hex: #fff2f0"""
 43    LIGHT_BROWN = "light-brown"
 44    """Hex: #f5e6dc"""
 45    LIGHT_PURPLE = "light-purple"
 46    """Hex: #f9f1fd"""
 47    LIGHT_PINK = "light-pink"
 48    """Hex: #f7e1f2"""
 49    LIGHT_GRAY = "light-gray"
 50    """Hex: #f5f5f5"""
 51    BLUE = "blue"
 52    """Hex: #dae4fd"""
 53    GREEN = "green"
 54    """Hex: #d0f6dc"""
 55    CYAN = "cyan"
 56    """Hex: #a0ebf5"""
 57    YELLOW = "yellow"
 58    """Hex: #ffe9b4"""
 59    ORANGE = "orange"
 60    """Hex: #fff4da"""
 61    RED = "red"
 62    """Hex: #ffdeda"""
 63    BROWN = "brown"
 64    """Hex: #f5ceb0"""
 65    PURPLE = "purple"
 66    """Hex: #dfb9f7"""
 67    PINK = "pink"
 68    """Hex: #f7b2e7"""
 69    GRAY = "gray"
 70    """Hex: #d7d8d9"""
 71    DARKER_BLUE = "darker-blue"
 72    """Hex: #689ef1"""
 73    DARKER_GREEN = "darker-green"
 74    """Hex: #41dd75"""
 75    DARKER_CYAN = "darker-cyan"
 76    """Hex: #41d6ea"""
 77    DARKER_YELLOW = "darker-yellow"
 78    """Hex: #ffd269"""
 79    DARKER_ORANGE = "darker-orange"
 80    """Hex: #ffd269"""
 81    DARKER_RED = "darker-red"
 82    """Hex: #ff7b69"""
 83    DARKER_BROWN = "darker-brown"
 84    """Hex: #f5a96e"""
 85    DARKER_PURPLE = "darker-purple"
 86    """Hex: #bf73ee"""
 87    DARKER_PINK = "darker-pink"
 88    """Hex: #ff6dde"""
 89    DARKER_GRAY = "darker-gray"
 90    """Hex: #b5b5b7"""
 91
 92    @classmethod
 93    def random(cls):
 94        """
 95        Returns a random color.
 96        """
 97        return random.choice(list(cls))
 98
 99
100class BasicColor(str, enum.Enum):
101    """
102    Limited color palette from Baserow, as used in the rating field, for
103    example.
104    """
105
106    DARK_BLUE = "dark-blue"
107    """Hex: #acc8f8"""
108    DARK_GREEN = "dark-green"
109    """Hex: #a0eeba"""
110    DARK_YELLOW = "dark-yellow"
111    """Hex: #ffdd8f"""
112    DARK_RED = "dark-red"
113    """Hex: #ffbdb4"""
114
115    @classmethod
116    def random(cls) -> Self:
117        """
118        Returns a random color.
119        """
120        return random.choice(list(cls))
121
122
123class ColorSequence:
124    """
125    This class provides the ability to obtain appealing color gradients. Using
126    the method `ColorProvider.get_color()`, you can retrieve the colors
127    sequentially.
128    """
129
130    def __init__(self):
131        self.__current_index: int = 0
132
133    def get_color(self) -> Color:
134        """
135        Returns the next `Color` in the order of the Enum.
136        """
137        color_list = list(Color)
138        rsl = color_list[self.__current_index]
139        self.__current_index = (self.__current_index + 1) % len(color_list)
140        return rsl
class Color(builtins.str, enum.Enum):
 9class Color(str, enum.Enum):
10    """The colors defined and provided by Baserow."""
11
12    DARK_BLUE = "dark-blue"
13    """Hex: #acc8f8"""
14    DARK_GREEN = "dark-green"
15    """Hex: #a0eeba"""
16    DARK_CYAN = "dark-cyan"
17    """Hex: #70e0ef"""
18    DARK_YELLOW = "dark-yellow"
19    """Hex: #ffdd8f"""
20    DARK_ORANGE = "dark-orange"
21    """Hex: #ffe9b4"""
22    DARK_RED = "dark-red"
23    """Hex: #ffbdb4"""
24    DARK_BROWN = "dark-brown"
25    """Hex: #f5c098"""
26    DARK_PURPLE = "dark-purple"
27    """Hex: #cf96f2"""
28    DARK_PINK = "dark-pink"
29    """Hex: #f285d9"""
30    DARK_GRAY = "dark-gray"
31    """Hex: #b5b5b7"""
32    LIGHT_BLUE = "light-blue"
33    """Hex: #f0f4fc"""
34    LIGHT_GREEN = "light-green"
35    """Hex: #ecfcf1"""
36    LIGHT_CYAN = "light-cyan"
37    """Hex: #cff5fa"""
38    LIGHT_YELLOW = "light-yellow"
39    """Hex: #fffbf0"""
40    LIGHT_ORANGE = "light-orange"
41    """Hex: #fffbf0"""
42    LIGHT_RED = "light-red"
43    """Hex: #fff2f0"""
44    LIGHT_BROWN = "light-brown"
45    """Hex: #f5e6dc"""
46    LIGHT_PURPLE = "light-purple"
47    """Hex: #f9f1fd"""
48    LIGHT_PINK = "light-pink"
49    """Hex: #f7e1f2"""
50    LIGHT_GRAY = "light-gray"
51    """Hex: #f5f5f5"""
52    BLUE = "blue"
53    """Hex: #dae4fd"""
54    GREEN = "green"
55    """Hex: #d0f6dc"""
56    CYAN = "cyan"
57    """Hex: #a0ebf5"""
58    YELLOW = "yellow"
59    """Hex: #ffe9b4"""
60    ORANGE = "orange"
61    """Hex: #fff4da"""
62    RED = "red"
63    """Hex: #ffdeda"""
64    BROWN = "brown"
65    """Hex: #f5ceb0"""
66    PURPLE = "purple"
67    """Hex: #dfb9f7"""
68    PINK = "pink"
69    """Hex: #f7b2e7"""
70    GRAY = "gray"
71    """Hex: #d7d8d9"""
72    DARKER_BLUE = "darker-blue"
73    """Hex: #689ef1"""
74    DARKER_GREEN = "darker-green"
75    """Hex: #41dd75"""
76    DARKER_CYAN = "darker-cyan"
77    """Hex: #41d6ea"""
78    DARKER_YELLOW = "darker-yellow"
79    """Hex: #ffd269"""
80    DARKER_ORANGE = "darker-orange"
81    """Hex: #ffd269"""
82    DARKER_RED = "darker-red"
83    """Hex: #ff7b69"""
84    DARKER_BROWN = "darker-brown"
85    """Hex: #f5a96e"""
86    DARKER_PURPLE = "darker-purple"
87    """Hex: #bf73ee"""
88    DARKER_PINK = "darker-pink"
89    """Hex: #ff6dde"""
90    DARKER_GRAY = "darker-gray"
91    """Hex: #b5b5b7"""
92
93    @classmethod
94    def random(cls):
95        """
96        Returns a random color.
97        """
98        return random.choice(list(cls))

The colors defined and provided by Baserow.

DARK_BLUE = <Color.DARK_BLUE: 'dark-blue'>

Hex: #acc8f8

DARK_GREEN = <Color.DARK_GREEN: 'dark-green'>

Hex: #a0eeba

DARK_CYAN = <Color.DARK_CYAN: 'dark-cyan'>

Hex: #70e0ef

DARK_YELLOW = <Color.DARK_YELLOW: 'dark-yellow'>

Hex: #ffdd8f

DARK_ORANGE = <Color.DARK_ORANGE: 'dark-orange'>

Hex: #ffe9b4

DARK_RED = <Color.DARK_RED: 'dark-red'>

Hex: #ffbdb4

DARK_BROWN = <Color.DARK_BROWN: 'dark-brown'>

Hex: #f5c098

DARK_PURPLE = <Color.DARK_PURPLE: 'dark-purple'>

Hex: #cf96f2

DARK_PINK = <Color.DARK_PINK: 'dark-pink'>

Hex: #f285d9

DARK_GRAY = <Color.DARK_GRAY: 'dark-gray'>

Hex: #b5b5b7

LIGHT_BLUE = <Color.LIGHT_BLUE: 'light-blue'>

Hex: #f0f4fc

LIGHT_GREEN = <Color.LIGHT_GREEN: 'light-green'>

Hex: #ecfcf1

LIGHT_CYAN = <Color.LIGHT_CYAN: 'light-cyan'>

Hex: #cff5fa

LIGHT_YELLOW = <Color.LIGHT_YELLOW: 'light-yellow'>

Hex: #fffbf0

LIGHT_ORANGE = <Color.LIGHT_ORANGE: 'light-orange'>

Hex: #fffbf0

LIGHT_RED = <Color.LIGHT_RED: 'light-red'>

Hex: #fff2f0

LIGHT_BROWN = <Color.LIGHT_BROWN: 'light-brown'>

Hex: #f5e6dc

LIGHT_PURPLE = <Color.LIGHT_PURPLE: 'light-purple'>

Hex: #f9f1fd

LIGHT_PINK = <Color.LIGHT_PINK: 'light-pink'>

Hex: #f7e1f2

LIGHT_GRAY = <Color.LIGHT_GRAY: 'light-gray'>

Hex: #f5f5f5

BLUE = <Color.BLUE: 'blue'>

Hex: #dae4fd

GREEN = <Color.GREEN: 'green'>

Hex: #d0f6dc

CYAN = <Color.CYAN: 'cyan'>

Hex: #a0ebf5

YELLOW = <Color.YELLOW: 'yellow'>

Hex: #ffe9b4

ORANGE = <Color.ORANGE: 'orange'>

Hex: #fff4da

RED = <Color.RED: 'red'>

Hex: #ffdeda

BROWN = <Color.BROWN: 'brown'>

Hex: #f5ceb0

PURPLE = <Color.PURPLE: 'purple'>

Hex: #dfb9f7

PINK = <Color.PINK: 'pink'>

Hex: #f7b2e7

GRAY = <Color.GRAY: 'gray'>

Hex: #d7d8d9

DARKER_BLUE = <Color.DARKER_BLUE: 'darker-blue'>

Hex: #689ef1

DARKER_GREEN = <Color.DARKER_GREEN: 'darker-green'>

Hex: #41dd75

DARKER_CYAN = <Color.DARKER_CYAN: 'darker-cyan'>

Hex: #41d6ea

DARKER_YELLOW = <Color.DARKER_YELLOW: 'darker-yellow'>

Hex: #ffd269

DARKER_ORANGE = <Color.DARKER_ORANGE: 'darker-orange'>

Hex: #ffd269

DARKER_RED = <Color.DARKER_RED: 'darker-red'>

Hex: #ff7b69

DARKER_BROWN = <Color.DARKER_BROWN: 'darker-brown'>

Hex: #f5a96e

DARKER_PURPLE = <Color.DARKER_PURPLE: 'darker-purple'>

Hex: #bf73ee

DARKER_PINK = <Color.DARKER_PINK: 'darker-pink'>

Hex: #ff6dde

DARKER_GRAY = <Color.DARKER_GRAY: 'darker-gray'>

Hex: #b5b5b7

@classmethod
def random(cls):
93    @classmethod
94    def random(cls):
95        """
96        Returns a random color.
97        """
98        return random.choice(list(cls))

Returns a random color.

Inherited Members
enum.Enum
name
value
builtins.str
encode
replace
split
rsplit
join
capitalize
casefold
title
center
count
expandtabs
find
partition
index
ljust
lower
lstrip
rfind
rindex
rjust
rstrip
rpartition
splitlines
strip
swapcase
translate
upper
startswith
endswith
removeprefix
removesuffix
isascii
islower
isupper
istitle
isspace
isdecimal
isdigit
isnumeric
isalpha
isalnum
isidentifier
isprintable
zfill
format
format_map
maketrans
class BasicColor(builtins.str, enum.Enum):
101class BasicColor(str, enum.Enum):
102    """
103    Limited color palette from Baserow, as used in the rating field, for
104    example.
105    """
106
107    DARK_BLUE = "dark-blue"
108    """Hex: #acc8f8"""
109    DARK_GREEN = "dark-green"
110    """Hex: #a0eeba"""
111    DARK_YELLOW = "dark-yellow"
112    """Hex: #ffdd8f"""
113    DARK_RED = "dark-red"
114    """Hex: #ffbdb4"""
115
116    @classmethod
117    def random(cls) -> Self:
118        """
119        Returns a random color.
120        """
121        return random.choice(list(cls))

Limited color palette from Baserow, as used in the rating field, for example.

DARK_BLUE = <BasicColor.DARK_BLUE: 'dark-blue'>

Hex: #acc8f8

DARK_GREEN = <BasicColor.DARK_GREEN: 'dark-green'>

Hex: #a0eeba

DARK_YELLOW = <BasicColor.DARK_YELLOW: 'dark-yellow'>

Hex: #ffdd8f

DARK_RED = <BasicColor.DARK_RED: 'dark-red'>

Hex: #ffbdb4

@classmethod
def random(cls) -> Self:
116    @classmethod
117    def random(cls) -> Self:
118        """
119        Returns a random color.
120        """
121        return random.choice(list(cls))

Returns a random color.

Inherited Members
enum.Enum
name
value
builtins.str
encode
replace
split
rsplit
join
capitalize
casefold
title
center
count
expandtabs
find
partition
index
ljust
lower
lstrip
rfind
rindex
rjust
rstrip
rpartition
splitlines
strip
swapcase
translate
upper
startswith
endswith
removeprefix
removesuffix
isascii
islower
isupper
istitle
isspace
isdecimal
isdigit
isnumeric
isalpha
isalnum
isidentifier
isprintable
zfill
format
format_map
maketrans
class ColorSequence:
124class ColorSequence:
125    """
126    This class provides the ability to obtain appealing color gradients. Using
127    the method `ColorProvider.get_color()`, you can retrieve the colors
128    sequentially.
129    """
130
131    def __init__(self):
132        self.__current_index: int = 0
133
134    def get_color(self) -> Color:
135        """
136        Returns the next `Color` in the order of the Enum.
137        """
138        color_list = list(Color)
139        rsl = color_list[self.__current_index]
140        self.__current_index = (self.__current_index + 1) % len(color_list)
141        return rsl

This class provides the ability to obtain appealing color gradients. Using the method ColorProvider.get_color(), you can retrieve the colors sequentially.

def get_color(self) -> Color:
134    def get_color(self) -> Color:
135        """
136        Returns the next `Color` in the order of the Enum.
137        """
138        color_list = list(Color)
139        rsl = color_list[self.__current_index]
140        self.__current_index = (self.__current_index + 1) % len(color_list)
141        return rsl

Returns the next Color in the order of the Enum.