Skip to content
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
111 changes: 72 additions & 39 deletions components/api/apiDescription.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import React from 'react';
import React, { useState } from 'react';
import { RichLink } from '../../uiComponents';
import RichReactMarkdown from '../../components/richReactMarkdown';
import Section from '../../components/api/section';
import { IGuideElementShort } from '../../model';
import { H3WithAnchor } from '../../uiComponents/titleWithAnchor';
import slugify from 'slugify';
Expand All @@ -11,42 +10,76 @@ const ApiDescription: React.FC<{
body: string;
guides: IGuideElementShort[];
title: string;
}> = ({ content_intro, guides, body, title }) => (
<Section id="api-description" title="Description">
<>
<div style={{backgroundColor: "#FFE9E6", color: "#B34000", padding: "1rem"}}>
<strong>⚠️ Ces informations ne sont plus mises à jour depuis le 20/11/2024.</strong><br />
Le site API.gouv.fr va progressivement être fusionné dans le catalogue unique data.gouv.fr. <br /><br />
Retrouvez la fiche d'information à jour de cette API sur la nouvelle page API de Data.gouv.fr <a href={`https://data.gouv.fr/fr/dataservices/${slugify(title.replace(/[|&$%<>]/g, ""))}`} target="_blank" rel="noopener noreferrer">⇢ Consulter la fiche à jour</a>
}> = ({ title }) => {
const [searchQuery, setSearchQuery] = useState(title);

const handleSearch = (e: React.FormEvent) => {
e.preventDefault();
const encodedQuery = encodeURIComponent(searchQuery);
window.location.href = `https://www.data.gouv.fr/fr/dataservices/?q=${encodedQuery}`;
};

return (
<div className="deprecation-notice">
<div className="search-container">
<h1>Rechercher "{title}" sur data.gouv.fr</h1>
<form onSubmit={handleSearch} className="search-form">
<input
type="text"
value={searchQuery}
onChange={(e) => setSearchQuery(e.target.value)}
placeholder="Rechercher sur data.gouv.fr..."
className="search-input"
/>
<button type="submit" className="search-button">
Rechercher sur data.gouv.fr
</button>
</form>
</div>

{content_intro && <RichReactMarkdown source={content_intro} />}
{guides.length > 0 && (
<>
<H3WithAnchor>Exemples d’application</H3WithAnchor>
<div className="default-grid api-examples">
{guides.map(guide => (
<RichLink
key={guide.slug}
title={guide.title}
image={
guide.image
? `/images/guides/thumbnail_${guide.image}`
: undefined
}
href={`/guides/${guide.slug}`}
/>
))}
</div>
</>
)}
<RichReactMarkdown source={body} />
</>
<style jsx>{`
.api-examples {
margin-bottom: 40px;
}
`}</style>
</Section>
);

<style jsx>{`
.deprecation-notice {
max-width: 800px;
margin: 0 auto;
padding: 2rem;
}

.search-container {
text-align: center;
margin-top: 2rem;
}

.search-form {
display: flex;
gap: 1rem;
max-width: 600px;
margin: 5rem auto;
}

.search-input {
flex: 1;
padding: 0.75rem;
border: 1px solid #ccc;
border-radius: 4px;
font-size: 1rem;
}

.search-button {
padding: 0.75rem 1.5rem;
background-color: #000091;
color: white;
border: none;
border-radius: 4px;
cursor: pointer;
font-size: 1rem;
}

.search-button:hover {
background-color: #1212ff;
}
`}</style>
</div>
);
};

export default ApiDescription;
2 changes: 0 additions & 2 deletions components/api/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,9 @@ import Partners from './partners';
import TechnicalDocumentation from './technical-documentation';
import ApiRelatedServices from './apiRelatedServices.tsx';
import ApiOpenDataSources from './apiOpenDataSources.tsx';
import PageHeader from './pageHeader';
import ApiDescription from './apiDescription';

export {
PageHeader,
Access,
SupportAndTeam,
Partners,
Expand Down
103 changes: 0 additions & 103 deletions components/api/pageHeader.tsx

This file was deleted.

24 changes: 13 additions & 11 deletions components/api/section.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,17 +7,19 @@ const Section = ({ id, title, children }) => {
This is a hidden anchor. It is a trick to avoid having the header hiding
the top of the page.
</a>
<h2 className="ui dividing header">
<a
href={`#${id}`}
aria-hidden="true"
tabIndex="-1"
className="header-anchor"
>
#
</a>
{title}
</h2>
{title && (
<h2 className="ui dividing header">
<a
href={`#${id}`}
aria-hidden="true"
tabIndex="-1"
className="header-anchor"
>
#
</a>
{title}
</h2>
)}

{children}

Expand Down
2 changes: 1 addition & 1 deletion components/footer/preFooter.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ const PreFooter = ({ background }) => (
</div>
<div>
<p>Vous voulez partager une API ?</p>
<ButtonLink href={constants.links.ADD_API} alt>
<ButtonLink href="https://guides.data.gouv.fr/guide-data.gouv.fr/api/publier-une-api" alt>
Partager votre API
</ButtonLink>
</div>
Expand Down
93 changes: 11 additions & 82 deletions pages/les-api/[slug].tsx
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@ import {
import Page from '../../layouts';

import {
PageHeader,
Access,
SupportAndTeam,
Partners,
Expand All @@ -26,7 +25,6 @@ import ApiDetails from '../../components/api/apiDetails';
import { HEADER_PAGE } from '../../components';

import constants from '../../constants';
import Feedback from '../../components/feedback';
import { IDataGouvDataset, fetchDatagouvDatasets } from '../../components/api/apiOpenDataSources';

interface IProps {
Expand Down Expand Up @@ -74,93 +72,24 @@ const API: React.FC<IProps> = ({ api, guides, datagouvDatasets }) => {
canonical={`https://api.gouv.fr/les-api/${slug}`}
usePreFooter={!hide_pre_footer}
>
<PageHeader
title={title}
logo={logo || constants.logo}
tagline={tagline}
owner={owner}
owner_acronym={owner_acronym}
owner_slug={owner_slug}
/>

<div id="description" className="fr-container">
<div className="right-column-grid">
<div className="left-column text-style">
<ApiDescription
guides={guides}
body={body}
content_intro={content_intro}
title={title}
/>

{datagouvDatasets.length > 0 && (
<ApiOpenDataSources datasetsList={datagouvDatasets} />
)}

<Feedback />
</div>
<div className="right-column info-column">
<Access
is_open={is_open}
slug={slug}
doc_swagger_link={doc_tech_link}
doc_external_link={doc_tech_external}
account_link={account_link}
/>
<SupportAndTeam
logo={logo}
owner={owner}
owner_acronym={owner_acronym}
owner_slug={owner_slug}
link={contact_link}
/>
<TechnicalDocumentation
swagger_link={doc_tech_link}
external_link={doc_tech_external}
slug={slug}
/>
<ApiDetails
monitoring={monitoring_description}
monitoring_link={monitoring_link}
rate_limiting={rate_limiting_description}
rate_limiting_resume={rate_limiting_resume}
rate_limiting_link={rate_limiting_link}
stats_detail={stats_detail_description}
stats_detail_resume={stats_detail_resume}
stats_detail_link={stats_detail_link}
uptime={uptime}
is_france_connected={is_france_connected}
/>

<Partners partners={partners} />
</div>
<div className="text-style">
<ApiDescription
guides={guides}
body={body}
content_intro={content_intro}
title={title}
/>

{datagouvDatasets.length > 0 && (
<ApiOpenDataSources datasetsList={datagouvDatasets} />
)}
</div>
</div>
<style jsx>{`
#description {
margin-bottom: 70px;
}

.right-column-grid {
display: grid;
grid-template-columns: 65% 31%;
grid-gap: 40px;
}

.info-column {
border-left: 2px solid ${constants.colors.lightBlue};
padding: 0 0 0 40px;
}
@media only screen and (min-width: 1px) and (max-width: 900px) {
.right-column-grid {
display: flex;
flex-direction: column-reverse;
}
.info-column {
border: none;
padding: 0;
}
}
`}</style>
</Page>
);
Expand Down
Loading