Skip to content

Commit

Permalink
fix: temporary workaround for option getitem method
Browse files Browse the repository at this point in the history
  • Loading branch information
machow committed Aug 16, 2024
1 parent 9c5e254 commit a7a2835
Showing 1 changed file with 14 additions and 4 deletions.
18 changes: 14 additions & 4 deletions reactable/render_gt.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,15 +10,25 @@
from great_tables._text import _process_text
from great_tables._gt_data import ColInfoTypeEnum
from great_tables._scss import compile_scss
from typing import TYPE_CHECKING
from typing import TYPE_CHECKING, Any

from .models import Column, Language, Theme, ColGroup
from . import Reactable
from .tags import as_react_style, to_widget
from ._tbl_data import subset_frame

if TYPE_CHECKING:
from great_tables._gt_data import Locale, Spanners, Heading, Footnotes, SourceNotes
from great_tables._gt_data import Locale, Spanners, Heading, Footnotes, SourceNotes, Options


class OptWrapper:
_d: Options

def __init__(self, d: Options):
self._d = d

def __getitem__(self, k: str) -> Any:
return self._d[k].value


def dict_to_css(dict_: dict[str, str]) -> str:
Expand Down Expand Up @@ -147,7 +157,7 @@ def _render(self: GT):

# add_css_styles()

table_id = self._options["table_id"] or random_id()
table_id = OptWrapper(self._options)["table_id"] or random_id()
locale = self._locale

# generate Language -------------------------------------------------------
Expand Down Expand Up @@ -244,7 +254,7 @@ def _render(self: GT):
)

# Generate theme ----------------------------------------------------------
opts = self._options
opts = OptWrapper(self._options)
theme = Theme(
color=opts["table_font_color"],
background_color=opts["table_background_color"],
Expand Down

0 comments on commit a7a2835

Please sign in to comment.