diff --git a/public/data.json b/public/data.json index 6e23b47..6baa7e0 100644 --- a/public/data.json +++ b/public/data.json @@ -111,7 +111,7 @@ }, { "id": 15, - "title": "Pull request body generation in WebUI", + "title": "PR body generation in WebUI", "videoUrl": "", "description": "Automatically generate detailed pull request bodies with Copilot in the webUI.", "ghes_support": false diff --git a/src/pages/Skus.jsx b/src/pages/Skus.jsx index eaab1bf..4af3aa5 100644 --- a/src/pages/Skus.jsx +++ b/src/pages/Skus.jsx @@ -1,34 +1,57 @@ -import React, { useEffect, useState } from 'react'; +import React, { useEffect, useState, Component } from 'react'; import { useNavigate } from 'react-router-dom'; import '../styles.css'; import getData from '../utils/getData'; import Header from './title-header'; const Skus = () => { - const [features, setFeatures] = useState({ business: [], enterprise: [] }); + const [features, setFeatures] = useState({ business: [], enterprise: [], ghesFiltered: true }); const navigate = useNavigate(); - const isOn = false; const handleClick = (id) => { // navigate to the video with the given id navigate(`/detail?videoId=${id}`); }; - const handleGHESToggle = () => { - // hide the videos that do not have the ghes_support tag - const ghesToggle = document.getElementById('ghes-toggle'); - const ghesSupport = document.getElementsByClassName('ghes-support'); + const getElementByKey = (key) => { + const element = document.querySelector(`[data-key="${key}"]`); + return element; + } - if (ghesToggle.checked) { - for (let i = 0; i < ghesSupport.length; i++) { - ghesSupport[i].style.display = 'block'; + const toggleFeature = (item, style) => { + if (!item.ghes_support) { + const feature = getElementByKey(item.id); + if (feature) { + feature.style.display = style; } } + } + + const handleGHESToggle = () => { + // show/hide the videos that do not have the ghes_support tag + if (features.ghesFiltered) { + features.ghesFiltered = false; + features.business.forEach(item => { + toggleFeature(item, 'block'); + }); + + features.enterprise.forEach(item => { + toggleFeature(item, 'block'); + }); + + document.getElementById('ghesToggle').classList.remove('on'); + } else { - for (let i = 0; i < ghesSupport.length; i++) { - ghesSupport[i].style.display = 'none'; - } + features.ghesFiltered = true; + features.business.forEach(item => { + toggleFeature(item, 'none'); + }); + + features.enterprise.forEach(item => { + toggleFeature(item, 'none'); + }); + document.getElementById('ghesToggle').classList.add('on'); } } @@ -37,7 +60,8 @@ const Skus = () => { .then(data => { const business = data.features.videos.find(feature => feature.sku === "GitHub Copilot Business"); const enterprise = data.features.videos.find(feature => feature.sku === "GitHub Copilot Enterprise"); - setFeatures({ business: business.items, enterprise: enterprise.items }); + setFeatures({ business: business.items, enterprise: enterprise.items, ghesFiltered: false }); + handleGHESToggle(); }) .catch(error => console.error('Error loading SKU data:', error)); }, []); @@ -45,9 +69,12 @@ const Skus = () => { return (
+ @@ -56,11 +83,11 @@ const Skus = () => {

GitHub Copilot Business

-
+
{ features.business.map(item => (
handleClick(item.id)} > @@ -75,11 +102,11 @@ const Skus = () => {

GitHub Copilot Enterprise

-
+
{features.enterprise.map(item => (
handleClick(item.id)}>

{item.title}

- {!item.videoUrl &&
Coming soon
} + {!item.videoUrl &&
Video coming soon
}
))}
diff --git a/src/styles.css b/src/styles.css index b92286c..8b8694c 100644 --- a/src/styles.css +++ b/src/styles.css @@ -35,7 +35,6 @@ .sku-grid { flex: 1; display: grid; - grid-template-columns: repeat(3, 1fr); margin-left: -5px; border: none; justify-content: center; @@ -50,6 +49,14 @@ padding: 10px; } +.sku-grid.business { + grid-template-columns: repeat(4, 1fr); +} + +.sku-grid.enterprise { + grid-template-columns: repeat(2, 1fr); +} + .grid-container { display: flex; justify-content: center; @@ -478,9 +485,5 @@ h1 { } .toggle-button.on { - background-color: #28a745; /* Green for ON state */ + background-color: red; } - -.toggle-button.off { - background-color: #dc3545; /* Red for OFF state */ -} \ No newline at end of file