mirror of
https://github.com/blitzkit/blitzkit.git
synced 2026-12-05 07:43:49 +01:00
feat: provision buttons
This commit is contained in:
1 parent
850308b2ac
commit
5d0fe8726b
1 file changed
+53
-3
@@ -23,6 +23,7 @@ import { usePathname, useRouter, useSearchParams } from 'next/navigation';
|
|||||||
import { use, useCallback, useEffect, useMemo, useState } from 'react';
|
import { use, useCallback, useEffect, useMemo, useState } from 'react';
|
||||||
import { EquipmentManager } from '../../../components/EquipmentManager';
|
import { EquipmentManager } from '../../../components/EquipmentManager';
|
||||||
import PageWrapper from '../../../components/PageWrapper';
|
import PageWrapper from '../../../components/PageWrapper';
|
||||||
|
import { asset } from '../../../core/blitzkrieg/asset';
|
||||||
import { equipmentDefinitions } from '../../../core/blitzkrieg/equipmentDefinitions';
|
import { equipmentDefinitions } from '../../../core/blitzkrieg/equipmentDefinitions';
|
||||||
import { modelDefinitions } from '../../../core/blitzkrieg/modelDefinitions';
|
import { modelDefinitions } from '../../../core/blitzkrieg/modelDefinitions';
|
||||||
import { provisionDefinitions } from '../../../core/blitzkrieg/provisionDefinitions';
|
import { provisionDefinitions } from '../../../core/blitzkrieg/provisionDefinitions';
|
||||||
@@ -86,6 +87,7 @@ export default function Page() {
|
|||||||
[searchParams],
|
[searchParams],
|
||||||
);
|
);
|
||||||
|
|
||||||
|
const test = Object.keys(awaitedProvisionDefinitions).slice(0, 1);
|
||||||
const hasNonRegularGun = members.some(({ gun }) => gun.type !== 'regular');
|
const hasNonRegularGun = members.some(({ gun }) => gun.type !== 'regular');
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
@@ -436,7 +438,8 @@ export default function Page() {
|
|||||||
<Table.Row>
|
<Table.Row>
|
||||||
<Table.Cell />
|
<Table.Cell />
|
||||||
|
|
||||||
{members.map(({ equipmentMatrix, tank, key }, index) => {
|
{members.map(
|
||||||
|
({ equipmentMatrix, tank, key, provisions }, index) => {
|
||||||
const equipmentPreset =
|
const equipmentPreset =
|
||||||
awaitedEquipmentDefinitions.presets[tank.equipment];
|
awaitedEquipmentDefinitions.presets[tank.equipment];
|
||||||
|
|
||||||
@@ -445,6 +448,7 @@ export default function Page() {
|
|||||||
<Flex
|
<Flex
|
||||||
align="center"
|
align="center"
|
||||||
justify="center"
|
justify="center"
|
||||||
|
gap="4"
|
||||||
style={{
|
style={{
|
||||||
width: '100%',
|
width: '100%',
|
||||||
height: '100%',
|
height: '100%',
|
||||||
@@ -540,7 +544,9 @@ export default function Page() {
|
|||||||
mutateCompareTemporary((draft) => {
|
mutateCompareTemporary((draft) => {
|
||||||
draft.members.forEach((member) => {
|
draft.members.forEach((member) => {
|
||||||
member.equipmentMatrix =
|
member.equipmentMatrix =
|
||||||
draft.members[index].equipmentMatrix;
|
draft.members[
|
||||||
|
index
|
||||||
|
].equipmentMatrix;
|
||||||
draft.sorting = undefined;
|
draft.sorting = undefined;
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
@@ -552,10 +558,54 @@ export default function Page() {
|
|||||||
</Flex>
|
</Flex>
|
||||||
</Popover.Content>
|
</Popover.Content>
|
||||||
</Popover.Root>
|
</Popover.Root>
|
||||||
|
|
||||||
|
<Button
|
||||||
|
variant="ghost"
|
||||||
|
radius="large"
|
||||||
|
style={{
|
||||||
|
height: '100%',
|
||||||
|
width: 16,
|
||||||
|
position: 'relative',
|
||||||
|
}}
|
||||||
|
>
|
||||||
|
<Flex direction="column">
|
||||||
|
{provisions.map((provision, index) => (
|
||||||
|
<img
|
||||||
|
key={provision}
|
||||||
|
src={asset(
|
||||||
|
`/icons/provisions/${provision}.webp`,
|
||||||
|
)}
|
||||||
|
style={{
|
||||||
|
left: '50%',
|
||||||
|
/**
|
||||||
|
* max = 100% - 16px - 4px
|
||||||
|
* min = 4px
|
||||||
|
* diff = max - min
|
||||||
|
* = 100% - 16px - 4px - 4px
|
||||||
|
* = 100% - 24px
|
||||||
|
* coefficient = index / length - 1
|
||||||
|
* position = min + coefficient * diff
|
||||||
|
*/
|
||||||
|
top: `calc(4px + ${
|
||||||
|
provisions.length === 1
|
||||||
|
? 0.5
|
||||||
|
: index / (provisions.length - 1)
|
||||||
|
} * (100% - 24px))`,
|
||||||
|
transform: 'translateX(-50%)',
|
||||||
|
position: 'absolute',
|
||||||
|
width: 16,
|
||||||
|
height: 16,
|
||||||
|
objectFit: 'contain',
|
||||||
|
}}
|
||||||
|
/>
|
||||||
|
))}
|
||||||
|
</Flex>
|
||||||
|
</Button>
|
||||||
</Flex>
|
</Flex>
|
||||||
</Table.Cell>
|
</Table.Cell>
|
||||||
);
|
);
|
||||||
})}
|
},
|
||||||
|
)}
|
||||||
</Table.Row>
|
</Table.Row>
|
||||||
</Table.Body>
|
</Table.Body>
|
||||||
|
|
||||||
|
|||||||
Reference in new issue
Block a user