Skip to content

Commit

Permalink
show/hide details via CSS rather than Javascript (#5396)
Browse files Browse the repository at this point in the history
  • Loading branch information
cj12312021 authored Oct 29, 2024
1 parent c6bcdd8 commit 069a4b1
Show file tree
Hide file tree
Showing 6 changed files with 81 additions and 93 deletions.
38 changes: 9 additions & 29 deletions ui/v2.5/src/components/Groups/GroupDetails/GroupDetailsPanel.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,6 @@ interface IGroupDetailsPanel {

export const GroupDetailsPanel: React.FC<IGroupDetailsPanel> = ({
group,
collapsed,
fullWidth,
}) => {
// Network state
Expand All @@ -55,32 +54,6 @@ export const GroupDetailsPanel: React.FC<IGroupDetailsPanel> = ({
);
}

function maybeRenderExtraDetails() {
if (!collapsed) {
return (
<>
<DetailItem
id="synopsis"
value={group.synopsis}
fullWidth={fullWidth}
/>
<DetailItem
id="tags"
value={renderTagsField()}
fullWidth={fullWidth}
/>
{group.containing_groups.length > 0 && (
<DetailItem
id="containing_groups"
value={<GroupsList groups={group.containing_groups} />}
fullWidth={fullWidth}
/>
)}
</>
);
}
}

return (
<div className="detail-group">
<DetailItem
Expand Down Expand Up @@ -108,7 +81,6 @@ export const GroupDetailsPanel: React.FC<IGroupDetailsPanel> = ({
}
fullWidth={fullWidth}
/>

<DetailItem
id="director"
value={
Expand All @@ -120,7 +92,15 @@ export const GroupDetailsPanel: React.FC<IGroupDetailsPanel> = ({
}
fullWidth={fullWidth}
/>
{maybeRenderExtraDetails()}
<DetailItem id="synopsis" value={group.synopsis} fullWidth={fullWidth} />
<DetailItem id="tags" value={renderTagsField()} fullWidth={fullWidth} />
{group.containing_groups.length > 0 && (
<DetailItem
id="containing_groups"
value={<GroupsList groups={group.containing_groups} />}
fullWidth={fullWidth}
/>
)}
</div>
);
};
Expand Down
17 changes: 15 additions & 2 deletions ui/v2.5/src/components/Groups/styles.scss
Original file line number Diff line number Diff line change
Expand Up @@ -41,8 +41,21 @@
}
}

#group-page .rating-number .text-input {
width: auto;
#group-page {
.rating-number .text-input {
width: auto;
}

// the detail element ids are the same as field type name
// which don't follow the correct convention
/* stylelint-disable selector-class-pattern */
.collapsed {
.detail-item.tags,
.detail-item.containing_groups {
display: none;
}
}
/* stylelint-enable selector-class-pattern */
}

.group-select-option {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ const PerformerDetailGroup: React.FC<PropsWithChildren<IPerformerDetails>> =

export const PerformerDetailsPanel: React.FC<IPerformerDetails> =
PatchComponent("PerformerDetailsPanel", (props) => {
const { performer, collapsed, fullWidth } = props;
const { performer, fullWidth } = props;

// Network state
const intl = useIntl();
Expand Down Expand Up @@ -62,45 +62,9 @@ export const PerformerDetailsPanel: React.FC<IPerformerDetails> =
);
}

function maybeRenderExtraDetails() {
if (!collapsed) {
/* Remove extra urls provided in details since they will be present by perfomr name */
/* This code can be removed once multple urls are supported for performers */
let details = performer?.details
?.replace(/\[((?:http|www\.)[^\n\]]+)\]/gm, "")
.trim();
return (
<>
<DetailItem
id="tattoos"
value={performer?.tattoos}
fullWidth={fullWidth}
/>
<DetailItem
id="piercings"
value={performer?.piercings}
fullWidth={fullWidth}
/>
<DetailItem
id="career_length"
value={performer?.career_length}
fullWidth={fullWidth}
/>
<DetailItem id="details" value={details} fullWidth={fullWidth} />
<DetailItem
id="tags"
value={renderTagsField()}
fullWidth={fullWidth}
/>
<DetailItem
id="stash_ids"
value={renderStashIDs()}
fullWidth={fullWidth}
/>
</>
);
}
}
let details = performer?.details
?.replace(/\[((?:http|www\.)[^\n\]]+)\]/gm, "")
.trim();

return (
<PerformerDetailGroup {...props}>
Expand Down Expand Up @@ -190,7 +154,28 @@ export const PerformerDetailsPanel: React.FC<IPerformerDetails> =
value={performer?.fake_tits}
fullWidth={fullWidth}
/>
{maybeRenderExtraDetails()}
<DetailItem
id="tattoos"
value={performer?.tattoos}
fullWidth={fullWidth}
/>
<DetailItem
id="piercings"
value={performer?.piercings}
fullWidth={fullWidth}
/>
<DetailItem
id="career_length"
value={performer?.career_length}
fullWidth={fullWidth}
/>
<DetailItem id="details" value={details} fullWidth={fullWidth} />
<DetailItem id="tags" value={renderTagsField()} fullWidth={fullWidth} />
<DetailItem
id="stash_ids"
value={renderStashIDs()}
fullWidth={fullWidth}
/>
</PerformerDetailGroup>
);
});
Expand Down
15 changes: 15 additions & 0 deletions ui/v2.5/src/components/Performers/styles.scss
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,21 @@
.alias {
font-weight: bold;
}

// the detail element ids are the same as field type name
// which don't follow the correct convention
/* stylelint-disable selector-class-pattern */
.collapsed {
.detail-item.tattoos,
.detail-item.piercings,
.detail-item.career_length,
.detail-item.details,
.detail-item.tags,
.detail-item.stash_ids {
display: none;
}
}
/* stylelint-enable selector-class-pattern */
}

.new-view {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@ interface IStudioDetailsPanel {

export const StudioDetailsPanel: React.FC<IStudioDetailsPanel> = ({
studio,
collapsed,
fullWidth,
}) => {
function renderTagsField() {
Expand Down Expand Up @@ -47,25 +46,6 @@ export const StudioDetailsPanel: React.FC<IStudioDetailsPanel> = ({
);
}

function maybeRenderExtraDetails() {
if (!collapsed) {
return (
<>
<DetailItem
id="tags"
value={renderTagsField()}
fullWidth={fullWidth}
/>
<DetailItem
id="stash_ids"
value={renderStashIDs()}
fullWidth={fullWidth}
/>
</>
);
}
}

return (
<div className="detail-group">
<DetailItem id="details" value={studio.details} fullWidth={fullWidth} />
Expand All @@ -82,7 +62,12 @@ export const StudioDetailsPanel: React.FC<IStudioDetailsPanel> = ({
}
fullWidth={fullWidth}
/>
{maybeRenderExtraDetails()}
<DetailItem id="tags" value={renderTagsField()} fullWidth={fullWidth} />
<DetailItem
id="stash_ids"
value={renderStashIDs()}
fullWidth={fullWidth}
/>
</div>
);
};
Expand Down
10 changes: 10 additions & 0 deletions ui/v2.5/src/components/Studios/styles.scss
Original file line number Diff line number Diff line change
Expand Up @@ -40,4 +40,14 @@
.rating-number .text-input {
width: auto;
}

// the detail element ids are the same as field type name
// which don't follow the correct convention
/* stylelint-disable selector-class-pattern */
.collapsed {
.detail-item.stash_ids {
display: none;
}
}
/* stylelint-enable selector-class-pattern */
}

0 comments on commit 069a4b1

Please sign in to comment.