Skip to content

Commit

Permalink
fix(ItinerarySegmentDetail): fix overflowing content issue
Browse files Browse the repository at this point in the history
  • Loading branch information
mainframev committed Oct 9, 2023
1 parent 6599337 commit bac87db
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 7 deletions.
4 changes: 2 additions & 2 deletions packages/orbit-components/src/Itinerary/Itinerary.stories.tsx
Expand Up @@ -182,7 +182,7 @@ const content = [

export const Segment = () => {
return (
<Stack spacing="large">
<div className="space-y-xl">
<Itinerary>
<ItinerarySegment>
<ItinerarySegmentStop
Expand Down Expand Up @@ -240,7 +240,7 @@ export const Segment = () => {
/>
</ItinerarySegment>
</Itinerary>
</Stack>
</div>
);
};

Expand Down
Expand Up @@ -21,7 +21,9 @@ import { usePart } from "../context";
import { useWidth } from "../../context";
import AirplaneDown from "../../../icons/AirplaneDown";
import type { Props } from "./types";
import type { SpaceAfterSizes } from "../../../common/types";
import ItineraryIcon from "../ItineraryIcon";
import getSpacingToken from "../../../common/getSpacingToken";

const StyledWrapper = styled.div`
width: 100%;
Expand Down Expand Up @@ -79,7 +81,7 @@ const StyledExpandableContent = styled.div<{ $offset: number }>`
padding: 0 ${theme.orbit.spaceSmall};
position: relative;
z-index: 1;
margin-${left}: ${parseInt(theme.orbit.spaceXSmall, 10) + $offset}px;
${left}: ${parseInt(theme.orbit.spaceXSmall, 10) + $offset}px;
`}
`;

Expand Down Expand Up @@ -128,6 +130,20 @@ const StyledIcon = styled.div<{ isFirst?: boolean; isLast?: boolean }>`
`}
`;

const StyledItemWrapper = styled.div<{ $offset: number; spaceAfter: SpaceAfterSizes }>`
${({ theme, $offset }) => css`
display: flex;
align-items: center;
flex-direction: column;
width: calc(100% - ${parseInt(theme.orbit.spaceXSmall, 10) + $offset}px);
margin-bottom: ${getSpacingToken};
`};
`;

StyledItemWrapper.defaultProps = {
theme: themeDefault,
};

StyledIcon.defaultProps = {
theme: themeDefault,
};
Expand Down Expand Up @@ -199,9 +215,8 @@ const ItinerarySegmentDetail = ({
{title}
</TemporaryText>
</StyledHeadingOffset>
<Stack
direction="column"
spacing="none"
<StyledItemWrapper
$offset={calculatedWidth}
spaceAfter={idx === content.length - 1 ? "none" : "medium"}
>
{items.map(({ icon: itemIcon, name, value }, id) => {
Expand All @@ -222,7 +237,7 @@ const ItinerarySegmentDetail = ({
</Stack>
);
})}
</Stack>
</StyledItemWrapper>
</React.Fragment>
);
})}
Expand Down

0 comments on commit bac87db

Please sign in to comment.