Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(FEC-13659): handle media info responsiveness #97

Merged
merged 1 commit into from
Feb 20, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
29 changes: 21 additions & 8 deletions src/components/info/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ const {
redux: {connect}
} = KalturaPlayer.ui;
const {Overlay} = KalturaPlayer.ui.components;
const {Text} = KalturaPlayer.ui.preacti18n;
const {Text, withText} = KalturaPlayer.ui.preacti18n;
// @ts-ignore
const {withKeyboardA11y} = KalturaPlayer.ui.utils;

Expand All @@ -18,6 +18,8 @@ export interface InfoProps {
creator: string;
createdAt: VNode;
plays: string;
creatorText?: string;
playsText?: string;
}
interface ConnectProps {
playerSize?: string;
Expand All @@ -33,27 +35,38 @@ type MergedProps = InfoProps & ConnectProps & KeyboardA11yProps;
const mapStateToProps = (state: Record<string, any>) => ({
playerSize: state.shell.playerSize
});

const translates = ({plays, creator}: InfoProps) => {
return {
creatorText: <Text id="info.creator" fields={{creator}}>{`By ${creator}`}</Text>,
playsText: <Text id="info.plays" fields={{plays}}>{`${plays} plays`}</Text>
};
};

@connect(mapStateToProps)
@withKeyboardA11y
@withText(translates)
export class Info extends Component<MergedProps> {
renderMediaInfo = () => {
const {creator, createdAt, plays} = this.props;
const mediaInfo = [creator, plays, createdAt];
const {creator, createdAt, plays, creatorText, playsText} = this.props;

const creatorObj: any = creator ? {value: creatorText!, dataTestId: 'creator', title: creatorText} : null;
const playsObj: any = plays ? {value: playsText!, dataTestId: 'plays', title: playsText} : null;
const createdAtObj: any = createdAt ? {value: createdAt, dataTestId: 'createdAt', title: createdAt.props.children as string} : null;

const mediaInfo: any[] = [creatorObj, playsObj, createdAtObj];
if (!mediaInfo.some(v => v)) {
return null;
}
const dataTestIds = ['creator', 'plays', 'createdAt'];
return (
<div className={styles.mediaInfo} data-testid="mediaInfo">
{mediaInfo.map((val, index) => {
if (!val) {
return null;
}
return (
<div key={index} className={styles.mediaInfoBlock} data-testid={dataTestIds[index]}>
{index === 0 ? <Text id="info.creator">By </Text> : null}
{val}
{index === 1 ? <Text id="info.plays"> plays</Text> : null}
<div key={index} className={styles.mediaInfoBlock} data-testid={val.dataTestId} title={val.title}>
{val.value}
</div>
);
})}
Expand Down
15 changes: 12 additions & 3 deletions src/components/info/info.scss
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,15 @@
}
&.extrasmall,
&.small {
padding: 0;
.entryName {
font-size: 18px;
}
.mediaInfoBlock:first-child {
text-overflow: ellipsis;
overflow: hidden;
min-width: 24px;
}
}
&.medium,
&.large,
Expand Down Expand Up @@ -49,10 +55,13 @@
font-style: normal;
font-weight: 400;
line-height: 18px;
.mediaInfoBlock:not(:last-child) {
&::after {
.mediaInfoBlock {
white-space: nowrap;
}
.mediaInfoBlock:not(:first-child) {
&::before {
content: '|';
margin: 0 10px;
margin: 0 8px;
}
}
}
Expand Down
4 changes: 2 additions & 2 deletions translations/en.i18n.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@
},
"info": {
"info": "Info",
"creator": "By ",
"plays": " plays",
"creator": "By {{creator}}",
"plays": "{{plays}} plays",
"live": "Live now",
"today": "Today",
"daysAgo": "{{daysSince}} days ago",
Expand Down
Loading