10 changed files with 394 additions and 111 deletions
@ -0,0 +1,86 @@ |
|||
""" |
|||
The MIT License (MIT) |
|||
|
|||
Copyright (c) 2015-present Rapptz |
|||
|
|||
Permission is hereby granted, free of charge, to any person obtaining a |
|||
copy of this software and associated documentation files (the "Software"), |
|||
to deal in the Software without restriction, including without limitation |
|||
the rights to use, copy, modify, merge, publish, distribute, sublicense, |
|||
and/or sell copies of the Software, and to permit persons to whom the |
|||
Software is furnished to do so, subject to the following conditions: |
|||
|
|||
The above copyright notice and this permission notice shall be included in |
|||
all copies or substantial portions of the Software. |
|||
|
|||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS |
|||
OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, |
|||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE |
|||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER |
|||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING |
|||
FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER |
|||
DEALINGS IN THE SOFTWARE. |
|||
""" |
|||
from __future__ import annotations |
|||
|
|||
from typing import TYPE_CHECKING, List, Optional |
|||
|
|||
if TYPE_CHECKING: |
|||
from ..components import Component |
|||
from ..colour import Colour, Color |
|||
|
|||
__all__ = ('Container',) |
|||
|
|||
|
|||
class Container: |
|||
"""Represents a Components V2 Container. |
|||
|
|||
.. versionadded:: 2.6 |
|||
|
|||
Parameters |
|||
---------- |
|||
children: List[:class:`Item`] |
|||
The initial children of this container. |
|||
accent_colour: Optional[:class:`~discord.Colour`] |
|||
The colour of the container. Defaults to ``None``. |
|||
accent_color: Optional[:class:`~discord.Color`] |
|||
The color of the container. Defaults to ``None``. |
|||
spoiler: :class:`bool` |
|||
Whether to flag this container as a spoiler. Defaults |
|||
to ``False``. |
|||
""" |
|||
|
|||
__discord_ui_container__ = True |
|||
|
|||
def __init__( |
|||
self, |
|||
children: List[Component], |
|||
*, |
|||
accent_colour: Optional[Colour] = None, |
|||
accent_color: Optional[Color] = None, |
|||
spoiler: bool = False, |
|||
) -> None: |
|||
self._children: List[Component] = children |
|||
self.spoiler: bool = spoiler |
|||
self._colour = accent_colour or accent_color |
|||
|
|||
@property |
|||
def children(self) -> List[Component]: |
|||
"""List[:class:`~discord.Component`]: The children of this container.""" |
|||
return self._children.copy() |
|||
|
|||
@children.setter |
|||
def children(self, value: List[Component]) -> None: |
|||
self._children = value |
|||
|
|||
@property |
|||
def accent_colour(self) -> Optional[Colour]: |
|||
"""Optional[:class:`~discord.Colour`]: The colour of the container, or ``None``.""" |
|||
return self._colour |
|||
|
|||
@accent_colour.setter |
|||
def accent_colour(self, value: Optional[Colour]) -> None: |
|||
self._colour = value |
|||
|
|||
accent_color = accent_colour |
|||
"""Optional[:class:`~discord.Color`]: The color of the container, or ``None``.""" |
@ -1,55 +0,0 @@ |
|||
""" |
|||
The MIT License (MIT) |
|||
|
|||
Copyright (c) 2015-present Rapptz |
|||
|
|||
Permission is hereby granted, free of charge, to any person obtaining a |
|||
copy of this software and associated documentation files (the "Software"), |
|||
to deal in the Software without restriction, including without limitation |
|||
the rights to use, copy, modify, merge, publish, distribute, sublicense, |
|||
and/or sell copies of the Software, and to permit persons to whom the |
|||
Software is furnished to do so, subject to the following conditions: |
|||
|
|||
The above copyright notice and this permission notice shall be included in |
|||
all copies or substantial portions of the Software. |
|||
|
|||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS |
|||
OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, |
|||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE |
|||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER |
|||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING |
|||
FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER |
|||
DEALINGS IN THE SOFTWARE. |
|||
""" |
|||
from __future__ import annotations |
|||
|
|||
from typing import List, Optional |
|||
|
|||
from .item import Item |
|||
from ..components import SectionComponent |
|||
|
|||
__all__ = ('Section',) |
|||
|
|||
|
|||
class Section(Item): |
|||
"""Represents a UI section. |
|||
|
|||
.. versionadded:: tbd |
|||
|
|||
Parameters |
|||
---------- |
|||
accessory: Optional[:class:`Item`] |
|||
The accessory to show within this section, displayed on the top right of this section. |
|||
""" |
|||
|
|||
__slots__ = ( |
|||
'accessory', |
|||
'_children', |
|||
) |
|||
|
|||
def __init__(self, *, accessory: Optional[Item]) -> None: |
|||
self.accessory: Optional[Item] = accessory |
|||
self._children: List[Item] = [] |
|||
self._underlying = SectionComponent._raw_construct( |
|||
accessory=accessory, |
|||
) |
Loading…
Reference in new issue