Skip to content

Commit

Permalink
Add logos for platform and framework icons (#16)
Browse files Browse the repository at this point in the history
  • Loading branch information
MattiasBuelens authored Mar 18, 2024
1 parent de9a5cc commit 0d6a3c6
Show file tree
Hide file tree
Showing 43 changed files with 105 additions and 42 deletions.
4 changes: 2 additions & 2 deletions sidebarsOpenVideoUI.ts
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ const sidebars: SidebarsConfig = {
label: 'React',
description: 'Build a stunning player UI with React components.',
customProps: {
icon: '⚛️',
icon: 'react',
},
link: {
type: 'generated-index',
Expand Down Expand Up @@ -82,7 +82,7 @@ const sidebars: SidebarsConfig = {
label: 'Android',
description: 'Build a mobile-first player UI for Android with Jetpack Compose.',
customProps: {
icon: '🤖',
icon: 'android',
},
link: {
type: 'generated-index',
Expand Down
4 changes: 2 additions & 2 deletions sidebarsTheoplayer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ const sidebars: SidebarsConfig = {
label: 'Android',
description: 'API references for the THEOplayer Android SDK',
customProps: {
icon: '🤖',
icon: 'android',
},
href: 'pathname:///theoplayer/v6/api-reference/android/',
},
Expand All @@ -96,7 +96,7 @@ const sidebars: SidebarsConfig = {
label: 'iOS',
description: 'API references for the THEOplayer iOS/tvOS SDK',
customProps: {
icon: '🍎',
icon: 'apple',
},
href: 'pathname:///theoplayer/v6/api-reference/ios/',
},
Expand Down
62 changes: 54 additions & 8 deletions src/theme/DocCard/index.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import React from 'react';
import React, { type JSX } from 'react';
import clsx from 'clsx';
import Link from '@docusaurus/Link';
import { findFirstSidebarItemLink, useDocById } from '@docusaurus/theme-common/internal';
Expand All @@ -8,6 +8,16 @@ import type { Props } from '@theme/DocCard';
import type { PropSidebarItemCategory, PropSidebarItemLink } from '@docusaurus/plugin-content-docs';
import Heading from '@theme/Heading';
import styles from './styles.module.css';
import AmpIcon from '@site/static/img/amp.svg';
import AndroidIcon from '@site/static/img/android.svg';
import AngularIcon from '@site/static/img/angular.svg';
import AppleIcon from '@site/static/img/apple.svg';
import ChromecastIcon from '@site/static/img/chromecast.svg';
import FlutterIcon from '@site/static/img/flutter.svg';
import NuxtjsIcon from '@site/static/img/nuxtjs.svg';
import ReactIcon from '@site/static/img/react.svg';
import VuejsIcon from '@site/static/img/vuejs.svg';
import WordPressIcon from '@site/static/img/wordpress.svg';

function CardContainer({ href, children }) {
return (
Expand All @@ -23,17 +33,53 @@ function CardLayout({ href, icon, title, description }) {
<Heading as="h2" className={clsx('text--truncate', styles.cardTitle)} title={title}>
{icon} {title}
</Heading>
{description && (
<p className={clsx(styles.cardDescription)}>
{description}
</p>
)}
{description && <p className={clsx(styles.cardDescription)}>{description}</p>}
</CardContainer>
);
}

interface SidebarItemCustomProps {
icon?: string;
}

interface CardIconProps {
item: PropSidebarItemCategory | PropSidebarItemLink;
defaultIcon: string;
}

function CardIcon({ item, defaultIcon }: CardIconProps): JSX.Element | string | null {
const icon = (item.customProps as SidebarItemCustomProps)?.icon;
if (!icon) {
return defaultIcon;
}
switch (icon) {
case 'amp':
return <AmpIcon className={clsx(styles.cardIcon)} />;
case 'android':
return <AndroidIcon className={clsx(styles.cardIcon)} />;
case 'angular':
return <AngularIcon className={clsx(styles.cardIcon)} />;
case 'apple':
return <AppleIcon className={clsx(styles.cardIcon)} />;
case 'chromecast':
return <ChromecastIcon className={clsx(styles.cardIcon)} />;
case 'flutter':
return <FlutterIcon className={clsx(styles.cardIcon)} />;
case 'nuxtjs':
return <NuxtjsIcon className={clsx(styles.cardIcon)} />;
case 'react':
return <ReactIcon className={clsx(styles.cardIcon)} />;
case 'vuejs':
return <VuejsIcon className={clsx(styles.cardIcon)} />;
case 'wordpress':
return <WordPressIcon className={clsx(styles.cardIcon)} />;
default:
return icon;
}
}

function CardCategory({ item }: { item: PropSidebarItemCategory }) {
const icon = item.customProps?.icon ?? '🗃️';
const icon = <CardIcon item={item} defaultIcon="🗃️" />;
const href = findFirstSidebarItemLink(item);
// Unexpected: categories that don't have a link have been filtered upfront
if (!href) {
Expand All @@ -60,7 +106,7 @@ function CardCategory({ item }: { item: PropSidebarItemCategory }) {
}

function CardLink({ item }: { item: PropSidebarItemLink }) {
const icon = item.customProps?.icon ?? (isInternalUrl(item.href) ? '📄️' : '🔗');
const icon = <CardIcon item={item} defaultIcon={isInternalUrl(item.href) ? '📄️' : '🔗'} />;
const doc = useDocById(item.docId ?? undefined);
return <CardLayout href={item.href} icon={icon} title={item.label} description={item.description ?? doc?.description} />;
}
Expand Down
7 changes: 7 additions & 0 deletions src/theme/DocCard/styles.module.css
Original file line number Diff line number Diff line change
Expand Up @@ -25,3 +25,10 @@
.cardDescription {
font-size: 0.8rem;
}

.cardIcon {
width: 1em;
height: 1em;
vertical-align: middle;
fill: var(--ifm-font-color-base);
}
1 change: 1 addition & 0 deletions static/img/amp.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
1 change: 1 addition & 0 deletions static/img/android.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
1 change: 1 addition & 0 deletions static/img/angular.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
1 change: 1 addition & 0 deletions static/img/apple.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
1 change: 1 addition & 0 deletions static/img/chromecast.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
1 change: 1 addition & 0 deletions static/img/flutter.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
1 change: 1 addition & 0 deletions static/img/nuxtjs.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
1 change: 1 addition & 0 deletions static/img/react.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
1 change: 1 addition & 0 deletions static/img/vuejs.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
1 change: 1 addition & 0 deletions static/img/wordpress.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"label": "Android",
"customProps": {
"icon": "🤖"
"icon": "android"
}
}
2 changes: 1 addition & 1 deletion theoplayer/getting-started/01-sdks/03-ios/_category_.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"label": "iOS & tvOS",
"customProps": {
"icon": "🍎"
"icon": "apple"
}
}
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"label": "Chromecast",
"customProps": {
"icon": "🛜"
"icon": "chromecast"
}
}
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"label": "Angular",
"customProps": {
"icon": "🅰️"
"icon": "angular"
}
}
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"label": "React",
"customProps": {
"icon": "⚛️"
"icon": "react"
}
}
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"label": "React Native",
"customProps": {
"icon": "⚛️"
"icon": "react"
}
}
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"label": "Nuxt.js",
"customProps": {
"icon": "⛰️"
"icon": "nuxtjs"
}
}
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"label": "Vue.js",
"customProps": {
"icon": "🌐"
"icon": "vuejs"
}
}
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"label": "AMP",
"customProps": {
"icon": ""
"icon": "amp"
}
}
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"label": "WordPress",
"customProps": {
"icon": "📝"
"icon": "wordpress"
}
}
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"label": "Flutter",
"customProps": {
"icon": "📱"
"icon": "flutter"
}
}
2 changes: 1 addition & 1 deletion theoplayer/how-to-guides/03-cast/_category_.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"label": "Cast",
"customProps": {
"icon": "🛜"
"icon": "chromecast"
}
}
2 changes: 1 addition & 1 deletion theoplayer/how-to-guides/13-objective-C/_category_.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"label": "Objective-C",
"customProps": {
"icon": "🍎"
"icon": "apple"
}
}
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"label": "Android",
"customProps": {
"icon": "🤖"
"icon": "android"
}
}
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"label": "iOS",
"customProps": {
"icon": "🍎"
"icon": "apple"
}
}
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"label": "Android TV",
"customProps": {
"icon": "🤖"
"icon": "android"
}
}
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"label": "tvOS",
"customProps": {
"icon": "🍎"
"icon": "apple"
}
}
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"label": "Chromecast",
"customProps": {
"icon": "🛜"
"icon": "chromecast"
}
}
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"label": "Angular",
"customProps": {
"icon": "🅰️"
"icon": "angular"
}
}
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"label": "React",
"customProps": {
"icon": "⚛️"
"icon": "react"
}
}
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"label": "React Native",
"customProps": {
"icon": "⚛️"
"icon": "react"
}
}
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"label": "Nuxt.js",
"customProps": {
"icon": "⛰️"
"icon": "nuxtjs"
}
}
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"label": "Vue.js",
"customProps": {
"icon": "🌐"
"icon": "vuejs"
}
}
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"label": "AMP",
"customProps": {
"icon": ""
"icon": "amp"
}
}
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"label": "WordPress",
"customProps": {
"icon": "📝"
"icon": "wordpress"
}
}
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"label": "Flutter",
"customProps": {
"icon": "📱"
"icon": "flutter"
}
}
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"label": "Cast",
"customProps": {
"icon": "🛜"
"icon": "chromecast"
}
}
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"label": "Objective-C",
"customProps": {
"icon": "🍎"
"icon": "apple"
}
}
Loading

0 comments on commit 0d6a3c6

Please sign in to comment.