1
0
mirror of https://github.com/uetchy/namae.git synced 2025-08-20 18:08:11 +09:00

feat: rubygems

This commit is contained in:
2019-08-02 16:27:05 +09:00
parent d856caadde
commit 72a70fe1a4
5 changed files with 72 additions and 4 deletions

View File

@@ -130,6 +130,30 @@ export function ExistentialAvailability({
)
}
export function CustomAvailability({
name,
target,
link,
prefix = '',
suffix = '',
icon,
children,
}) {
const response = useFetch(target, null, { metadata: true })
const availability = children(response)
return (
<Result
name={name}
availability={availability}
link={link}
prefix={prefix}
suffix={suffix}
icon={icon}
/>
)
}
const Container = styled.div`
min-height: 1em;
display: flex;

View File

@@ -4,7 +4,7 @@ import styled from 'styled-components'
import { AvailabilityContainer } from './Availability'
import { mobile } from '../util/css'
export function Card({ title, nameList, alternativeList = [], children }) {
export function Card({ title, nameList = [], alternativeList = [], children }) {
const [revealAlternatives, setRevealAlternatives] = useState(false)
function onClick() {
@@ -77,11 +77,10 @@ const CardList = styled.div`
const ShowAlternativesButton = styled.div`
display: inline-block;
margin-top: 10px;
padding: 5px 0;
border: none;
border-bottom: 1px dashed black;
cursor: pointer;
font-family: monospace;
font-size: 1rem;
font-size: 0.8em;
`

View File

@@ -0,0 +1,23 @@
import React from 'react'
import { FaGem } from 'react-icons/fa'
import { Card } from '../Cards'
import { DedicatedAvailability } from '../Availability'
export default function RubyGemsCard({ name }) {
return (
<Card
title="RubyGems"
key={name}
nameList={[name]}
alternativeList={[`${name.toLowerCase()}-rb`]}>
{(name) => (
<DedicatedAvailability
name={name}
service="rubygems"
link={`https://rubygems.org/gems/${name}`}
icon={<FaGem />}
/>
)}
</Card>
)
}