2025-08-05 18:37:07 +05:30
|
|
|
import React from 'react';
|
|
|
|
|
import { Box, Text, Icon, Icons, config, IconSrc } from 'folds';
|
|
|
|
|
import { SequenceCard } from '../sequence-card';
|
|
|
|
|
import { SettingTile } from '../setting-tile';
|
2026-03-07 18:03:32 +11:00
|
|
|
import { CreateRoomAccess } from './types';
|
2025-08-05 18:37:07 +05:30
|
|
|
|
2026-03-07 18:03:32 +11:00
|
|
|
type CreateRoomAccessSelectorProps = {
|
|
|
|
|
value?: CreateRoomAccess;
|
|
|
|
|
onSelect: (value: CreateRoomAccess) => void;
|
2025-08-05 18:37:07 +05:30
|
|
|
canRestrict?: boolean;
|
|
|
|
|
disabled?: boolean;
|
2026-03-07 18:03:32 +11:00
|
|
|
getIcon: (access: CreateRoomAccess) => IconSrc;
|
2025-08-05 18:37:07 +05:30
|
|
|
};
|
2026-03-07 18:03:32 +11:00
|
|
|
export function CreateRoomAccessSelector({
|
2025-08-05 18:37:07 +05:30
|
|
|
value,
|
|
|
|
|
onSelect,
|
|
|
|
|
canRestrict,
|
|
|
|
|
disabled,
|
|
|
|
|
getIcon,
|
2026-03-07 18:03:32 +11:00
|
|
|
}: CreateRoomAccessSelectorProps) {
|
2025-08-05 18:37:07 +05:30
|
|
|
return (
|
|
|
|
|
<Box shrink="No" direction="Column" gap="100">
|
|
|
|
|
{canRestrict && (
|
|
|
|
|
<SequenceCard
|
|
|
|
|
style={{ padding: config.space.S300 }}
|
2026-03-07 18:03:32 +11:00
|
|
|
variant={value === CreateRoomAccess.Restricted ? 'Primary' : 'SurfaceVariant'}
|
2025-08-05 18:37:07 +05:30
|
|
|
direction="Column"
|
|
|
|
|
gap="100"
|
|
|
|
|
as="button"
|
|
|
|
|
type="button"
|
2026-03-07 18:03:32 +11:00
|
|
|
aria-pressed={value === CreateRoomAccess.Restricted}
|
|
|
|
|
onClick={() => onSelect(CreateRoomAccess.Restricted)}
|
2025-08-05 18:37:07 +05:30
|
|
|
disabled={disabled}
|
|
|
|
|
>
|
|
|
|
|
<SettingTile
|
2026-03-07 18:03:32 +11:00
|
|
|
before={<Icon size="400" src={getIcon(CreateRoomAccess.Restricted)} />}
|
|
|
|
|
after={value === CreateRoomAccess.Restricted && <Icon src={Icons.Check} />}
|
2025-08-05 18:37:07 +05:30
|
|
|
>
|
|
|
|
|
<Text size="H6">Restricted</Text>
|
|
|
|
|
<Text size="T300" priority="300">
|
|
|
|
|
Only member of parent space can join.
|
|
|
|
|
</Text>
|
|
|
|
|
</SettingTile>
|
|
|
|
|
</SequenceCard>
|
|
|
|
|
)}
|
|
|
|
|
<SequenceCard
|
|
|
|
|
style={{ padding: config.space.S300 }}
|
2026-03-07 18:03:32 +11:00
|
|
|
variant={value === CreateRoomAccess.Private ? 'Primary' : 'SurfaceVariant'}
|
2025-08-05 18:37:07 +05:30
|
|
|
direction="Column"
|
|
|
|
|
gap="100"
|
|
|
|
|
as="button"
|
|
|
|
|
type="button"
|
2026-03-07 18:03:32 +11:00
|
|
|
aria-pressed={value === CreateRoomAccess.Private}
|
|
|
|
|
onClick={() => onSelect(CreateRoomAccess.Private)}
|
2025-08-05 18:37:07 +05:30
|
|
|
disabled={disabled}
|
|
|
|
|
>
|
|
|
|
|
<SettingTile
|
2026-03-07 18:03:32 +11:00
|
|
|
before={<Icon size="400" src={getIcon(CreateRoomAccess.Private)} />}
|
|
|
|
|
after={value === CreateRoomAccess.Private && <Icon src={Icons.Check} />}
|
2025-08-05 18:37:07 +05:30
|
|
|
>
|
|
|
|
|
<Text size="H6">Private</Text>
|
|
|
|
|
<Text size="T300" priority="300">
|
|
|
|
|
Only people with invite can join.
|
|
|
|
|
</Text>
|
|
|
|
|
</SettingTile>
|
|
|
|
|
</SequenceCard>
|
|
|
|
|
<SequenceCard
|
|
|
|
|
style={{ padding: config.space.S300 }}
|
2026-03-07 18:03:32 +11:00
|
|
|
variant={value === CreateRoomAccess.Public ? 'Primary' : 'SurfaceVariant'}
|
2025-08-05 18:37:07 +05:30
|
|
|
direction="Column"
|
|
|
|
|
gap="100"
|
|
|
|
|
as="button"
|
|
|
|
|
type="button"
|
2026-03-07 18:03:32 +11:00
|
|
|
aria-pressed={value === CreateRoomAccess.Public}
|
|
|
|
|
onClick={() => onSelect(CreateRoomAccess.Public)}
|
2025-08-05 18:37:07 +05:30
|
|
|
disabled={disabled}
|
|
|
|
|
>
|
|
|
|
|
<SettingTile
|
2026-03-07 18:03:32 +11:00
|
|
|
before={<Icon size="400" src={getIcon(CreateRoomAccess.Public)} />}
|
|
|
|
|
after={value === CreateRoomAccess.Public && <Icon src={Icons.Check} />}
|
2025-08-05 18:37:07 +05:30
|
|
|
>
|
|
|
|
|
<Text size="H6">Public</Text>
|
|
|
|
|
<Text size="T300" priority="300">
|
|
|
|
|
Anyone with the address can join.
|
|
|
|
|
</Text>
|
|
|
|
|
</SettingTile>
|
|
|
|
|
</SequenceCard>
|
|
|
|
|
</Box>
|
|
|
|
|
);
|
|
|
|
|
}
|