Skip to content

Commit

Permalink
stuff
Browse files Browse the repository at this point in the history
  • Loading branch information
silicons committed Jul 6, 2023
1 parent 2d21007 commit 8c1dacc
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 4 deletions.
5 changes: 4 additions & 1 deletion tgui/docs/component-reference.md
Original file line number Diff line number Diff line change
Expand Up @@ -727,6 +727,8 @@ systems for rendering. Modules are automatically centered within themselves.
**Props:**

- See inherited props: [Box](#box)
- `id` - the ID of the module, as per from within BYOND
- `section` - override props for the <Section> that the module renders in.

### `NoticeBox`

Expand Down Expand Up @@ -1210,6 +1212,7 @@ Known bugs:

**Props:**

- See inherited props: [Window](#window)
- `direct: InfernoNode` - Child elements that are rendered directly inside the window
when in standalone mode, and at the same level as other child elements when in embedded mode.
- `window: WindowProps` - Props from [Window][#window] to use in standalone mode.
- `section: SectionProps` - Props from [Section][#section] to use when in embedded mode. Overridden by the <Module>'s `section` entry.
6 changes: 5 additions & 1 deletion tgui/packages/tgui/backend.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@

import { perf } from 'common/perf';
import { createAction } from 'common/redux';
import { SectionProps } from './components/Section';
import { setupDrag } from './drag';
import { globalEvents } from './events';
import { focusMap } from './focus';
Expand Down Expand Up @@ -437,7 +438,10 @@ export const useSharedState = <T>(
//* TGUI Module Backend

export interface ModuleProps {
id: string, // module id, this lets it autoload from context
// module id, this lets it autoload from context
id: string;
// override props for rendering its external <Section>
section: SectionProps;
}

export interface ModuleData {
Expand Down
1 change: 1 addition & 0 deletions tgui/packages/tgui/components/Module.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ export class Module<T extends ModuleProps> extends Component<T, {}> {
return {
...this.context,
is_module: true,
m_section: this.props.section,
m_id: id,
m_ref: ref,
m_tgui: ui_name,
Expand Down
10 changes: 8 additions & 2 deletions tgui/packages/tgui/layouts/Modular.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,11 @@ export interface ModularProps {
* If not rendering directly, it will act like a <Section>.
*/
export const Modular = (props: ModularProps, context: any) => {
const { is_module } = context;
const { is_module, m_section } = context;
let sectionProps = {
...props.section,
...m_section,
};
return (
!is_module? (
<Window {...props.window}>
Expand All @@ -34,7 +38,9 @@ export const Modular = (props: ModularProps, context: any) => {
</Window.Content>
</Window>
) : (
<Section {...props.section}>
<Section
{...props.section}
{...sectionProps}>
{props.direct}
{props.children}
</Section>
Expand Down

0 comments on commit 8c1dacc

Please sign in to comment.