Skip to content

Commit b6ba1f5

Browse files
YLouWashUmeta-codesync[bot]
authored andcommitted
{Documentation} Add Colab buttons to website.
Summary: This diff adds the clickable Colab notebook buttons to the website. Reviewed By: PiotrBrzyski Differential Revision: D86066615 fbshipit-source-id: ec834cc87e15c0f34c51b1c70637f6e07dd2ea61
1 parent 1557af1 commit b6ba1f5

File tree

8 files changed

+63
-38
lines changed

8 files changed

+63
-38
lines changed

website/docs-research-tools/projectariatools/pythontutorials/calibration.mdx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ import TutorialButtons from '@site/src/components/TutorialButtons';
99

1010
<TutorialButtons
1111
notebookUrl="https://github.com/facebookresearch/projectaria_tools/blob/main/examples/Gen2/python_notebooks/Tutorial_2_device_calibration.ipynb"
12-
colabDisabled={true}
12+
colabUrl="https://colab.research.google.com/github/facebookresearch/projectaria_tools/blob/main/examples/Gen2/python_notebooks/Tutorial_2_device_calibration.ipynb"
1313
/>
1414

1515
## Introduction

website/docs-research-tools/projectariatools/pythontutorials/dataprovider.mdx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ import TutorialButtons from '@site/src/components/TutorialButtons';
99

1010
<TutorialButtons
1111
notebookUrl="https://github.com/facebookresearch/projectaria_tools/blob/main/examples/Gen2/python_notebooks/Tutorial_1_vrs_data_provider_basics.ipynb"
12-
colabDisabled={true}
12+
colabUrl="https://colab.research.google.com/github/facebookresearch/projectaria_tools/blob/main/examples/Gen2/python_notebooks/Tutorial_1_vrs_data_provider_basics.ipynb"
1313
/>
1414

1515
## Introduction

website/docs-research-tools/projectariatools/pythontutorials/eyetracking-handtracking.mdx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ import TutorialButtons from '@site/src/components/TutorialButtons';
99

1010
<TutorialButtons
1111
notebookUrl="https://github.com/facebookresearch/projectaria_tools/blob/main/examples/Gen2/python_notebooks/Tutorial_4_on_device_eyetracking_handtracking.ipynb"
12-
colabDisabled={true}
12+
colabUrl="https://colab.research.google.com/github/facebookresearch/projectaria_tools/blob/main/examples/Gen2/python_notebooks/Tutorial_4_on_device_eyetracking_handtracking.ipynb"
1313
/>
1414

1515
## Introduction

website/docs-research-tools/projectariatools/pythontutorials/mps.mdx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ import TutorialButtons from '@site/src/components/TutorialButtons';
99

1010
<TutorialButtons
1111
notebookUrl="https://github.com/facebookresearch/projectaria_tools/blob/main/examples/Gen2/python_notebooks/Tutorial_7_mps_data_provider_basics.ipynb"
12-
colabDisabled={true}
12+
colabUrl="https://colab.research.google.com/github/facebookresearch/projectaria_tools/blob/main/examples/Gen2/python_notebooks/Tutorial_7_mps_data_provider_basics.ipynb"
1313
/>
1414

1515
## Introduction

website/docs-research-tools/projectariatools/pythontutorials/queue.mdx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ import TutorialButtons from '@site/src/components/TutorialButtons';
99

1010
<TutorialButtons
1111
notebookUrl="https://github.com/facebookresearch/projectaria_tools/blob/main/examples/Gen2/python_notebooks/Tutorial_3_sequential_access_multi_sensor_data.ipynb"
12-
colabDisabled={true}
12+
colabUrl="https://colab.research.google.com/github/facebookresearch/projectaria_tools/blob/main/examples/Gen2/python_notebooks/Tutorial_3_sequential_access_multi_sensor_data.ipynb"
1313
/>
1414

1515
## Introduction

website/docs-research-tools/projectariatools/pythontutorials/time-sync.mdx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ import TutorialButtons from '@site/src/components/TutorialButtons';
99

1010
<TutorialButtons
1111
notebookUrl="https://github.com/facebookresearch/projectaria_tools/blob/main/examples/Gen2/python_notebooks/Tutorial_6_timestamp_alignment_in_aria_gen2.ipynb"
12-
colabDisabled={true}
12+
colabUrl="https://colab.research.google.com/github/facebookresearch/projectaria_tools/blob/main/examples/Gen2/python_notebooks/Tutorial_6_timestamp_alignment_in_aria_gen2.ipynb"
1313
/>
1414

1515
## Introduction

website/docs-research-tools/projectariatools/pythontutorials/vio.mdx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ import TutorialButtons from '@site/src/components/TutorialButtons';
99

1010
<TutorialButtons
1111
notebookUrl="https://github.com/facebookresearch/projectaria_tools/blob/main/examples/Gen2/python_notebooks/Tutorial_5_on_device_vio.ipynb"
12-
colabDisabled={true}
12+
colabUrl="https://colab.research.google.com/github/facebookresearch/projectaria_tools/blob/main/examples/Gen2/python_notebooks/Tutorial_5_on_device_vio.ipynb"
1313
/>
1414

1515
## Introduction

website/src/components/TutorialButtons.tsx

Lines changed: 56 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -18,11 +18,13 @@ import React from 'react';
1818

1919
interface TutorialButtonsProps {
2020
notebookUrl: string;
21+
colabUrl?: string;
2122
colabDisabled?: boolean;
2223
}
2324

2425
const TutorialButtons: React.FC<TutorialButtonsProps> = ({
2526
notebookUrl,
27+
colabUrl,
2628
colabDisabled = false,
2729
}) => {
2830
const handleColabClick = () => {
@@ -31,6 +33,15 @@ const TutorialButtons: React.FC<TutorialButtonsProps> = ({
3133
);
3234
};
3335

36+
const ColabIcon = () => (
37+
<svg
38+
style={{marginRight: '8px', width: '16px', height: '16px'}}
39+
fill="currentColor"
40+
viewBox="0 0 24 24">
41+
<path d="M16.9414 4.9757a7.033 7.033 0 0 0-4.9308 2.0324 7.033 7.033 0 0 0-.1232 9.8068l2.395-2.395a3.6455 3.6455 0 0 1 5.1497-5.1478l2.397-2.3989a7.033 7.033 0 0 0-4.8877-1.9175zM7.07 4.9855a7.033 7.033 0 0 0-4.8878 1.9175l2.395 2.3989a3.6434 3.6434 0 0 1 5.1497 5.1478l2.395 2.395a7.033 7.033 0 0 0-.1232-9.8068A7.033 7.033 0 0 0 7.07 4.9855zm15.0191 2.5923l-2.395 2.395a3.6455 3.6455 0 0 1-5.1497 5.1497l-2.395 2.395a7.033 7.033 0 0 0 9.9397-.123z" />
42+
</svg>
43+
);
44+
3445
return (
3546
<div
3647
style={{
@@ -71,39 +82,53 @@ const TutorialButtons: React.FC<TutorialButtonsProps> = ({
7182
View Notebook on GitHub
7283
</a>
7384

74-
<button
75-
onClick={handleColabClick}
76-
style={{
77-
display: 'inline-flex',
78-
alignItems: 'center',
79-
padding: '8px 16px',
80-
backgroundColor: colabDisabled ? '#f6f8fa' : '#f9ab00',
81-
border: '1px solid #d0d7de',
82-
borderRadius: '6px',
83-
color: colabDisabled ? '#656d76' : '#fff',
84-
fontSize: '14px',
85-
fontWeight: '500',
86-
cursor: colabDisabled ? 'not-allowed' : 'pointer',
87-
transition: 'background-color 0.2s',
88-
}}
89-
onMouseEnter={(e) => {
90-
if (!colabDisabled) {
85+
{!colabDisabled && colabUrl ? (
86+
<a
87+
href={colabUrl}
88+
target="_blank"
89+
rel="noopener noreferrer"
90+
style={{
91+
display: 'inline-flex',
92+
alignItems: 'center',
93+
padding: '8px 16px',
94+
backgroundColor: '#f9ab00',
95+
border: '1px solid #d0d7de',
96+
borderRadius: '6px',
97+
textDecoration: 'none',
98+
color: '#fff',
99+
fontSize: '14px',
100+
fontWeight: '500',
101+
transition: 'background-color 0.2s',
102+
}}
103+
onMouseEnter={(e) => {
91104
(e.target as HTMLElement).style.backgroundColor = '#e8a500';
92-
}
93-
}}
94-
onMouseLeave={(e) => {
95-
if (!colabDisabled) {
105+
}}
106+
onMouseLeave={(e) => {
96107
(e.target as HTMLElement).style.backgroundColor = '#f9ab00';
97-
}
98-
}}>
99-
<svg
100-
style={{marginRight: '8px', width: '16px', height: '16px'}}
101-
fill="currentColor"
102-
viewBox="0 0 24 24">
103-
<path d="M16.9414 4.9757a7.033 7.033 0 0 0-4.9308 2.0324 7.033 7.033 0 0 0-.1232 9.8068l2.395-2.395a3.6455 3.6455 0 0 1 5.1497-5.1478l2.397-2.3989a7.033 7.033 0 0 0-4.8877-1.9175zM7.07 4.9855a7.033 7.033 0 0 0-4.8878 1.9175l2.395 2.3989a3.6434 3.6434 0 0 1 5.1497 5.1478l2.395 2.395a7.033 7.033 0 0 0-.1232-9.8068A7.033 7.033 0 0 0 7.07 4.9855zm15.0191 2.5923l-2.395 2.395a3.6455 3.6455 0 0 1-5.1497 5.1497l-2.395 2.395a7.033 7.033 0 0 0 9.9397-.123z" />
104-
</svg>
105-
{colabDisabled ? 'Colab (Coming Soon)' : 'Run in Google Colab'}
106-
</button>
108+
}}>
109+
<ColabIcon />
110+
Run in Google Colab
111+
</a>
112+
) : (
113+
<button
114+
onClick={handleColabClick}
115+
style={{
116+
display: 'inline-flex',
117+
alignItems: 'center',
118+
padding: '8px 16px',
119+
backgroundColor: '#f6f8fa',
120+
border: '1px solid #d0d7de',
121+
borderRadius: '6px',
122+
color: '#656d76',
123+
fontSize: '14px',
124+
fontWeight: '500',
125+
cursor: 'not-allowed',
126+
transition: 'background-color 0.2s',
127+
}}>
128+
<ColabIcon />
129+
Colab (Coming Soon)
130+
</button>
131+
)}
107132
</div>
108133
);
109134
};

0 commit comments

Comments
 (0)