npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

@kenmori/corner-islands

v0.2.1

Published

corner-islands is a lightweight utility for dynamically determining the border-radius and other styles of connected elements in a sequence. By treating groups of elements as "islands," this package allows you to easily style connected corners, apply custo

Downloads

61

Readme

corner-islands

corner-islands is a lightweight utility for dynamically determining the border-radius and other styles of connected elements in a sequence. By treating groups of elements as "islands," this package allows you to easily style connected corners, apply custom styles, and manage layout logic based on the relationship between elements. Perfect for React and other UI frameworks where flexible, conditional styling is needed.

install

npm install corner-islands

API

getIsland(fields: { condition: 'And' | 'Or' }[]): (1 | 2 | 3 | 4)[]

Represents connections between elements as "islands" and returns the state of each element as a number.

1: Independent element (only one island)
2: Start of an island
3: Middle of an island
4: End of an island

Example

[2, 4, 2, 4] => Contains two islands

[2, 3, 3, 4] => One island composed of four elements

[2, 3, 4, 1] => Contains two islands

import { CornerIslands } from 'corner-islands';

const cornerIslands = new CornerIslands();

const fields = [
  { condition: 'And' },
  { condition: 'And' },
  { condition: 'Or' },
  { condition: 'And' }
];

const result = cornerIslands.getIsland(fields);
console.log(result); // [2, 3, 4, 1]

if you using react

const conditions = [{ condition: 'And' as const }];
const landsByOne = new CornerIslands().getIsland(conditions);
.
.
.
<Settings>
  {conditions.map((_, i) => {
    return (
      <Land land={landsByOne[i]}>
        <ConditionText>{i + 1}</ConditionText>
      </Land>
  );
  })}
</Settings>

//// style (ex: styled-components)
const Land = styled.div<{ land: 1 | 2 | 3 | 4 }>`
  padding: 8px 12px;
  font-weight: bold;
  align-items: center;
  display: flex;
  justify-content: center;
  border-radius: ${({ land }) =>
    land === 1
      ? '6px'
      : land === 2
      ? '6px 0 0 6px'
      : land === 3
      ? '0'
      : land === 4
      ? '0 6px 6px 0'
      : '0'};
  background: ${({ land }) => (land ? '#47cd47' : '#fff')}
`;

License

MIT License

Contributing

Issues and pull requests are welcome. For major changes, please open an issue first to discuss what you would like to change.

Author

@kenmori