All Projects → janosh → svelte-bricks

janosh / svelte-bricks

Licence: MIT license
Naive Svelte Masonry component without column balancing (ragged columns at the bottom)

Programming Languages

Svelte
593 projects
CSS
56736 projects
typescript
32286 projects
HTML
75241 projects
javascript
184084 projects - #8 most used programming language

Projects that are alternatives of or similar to svelte-bricks

Egjs Infinitegrid
A module used to arrange card elements including content infinitely on a grid layout.
Stars: ✭ 751 (+3313.64%)
Mutual labels:  layout, svelte, masonry
Masonry Layout
An efficient and fast web component that gives you a beautiful masonry layout
Stars: ✭ 43 (+95.45%)
Mutual labels:  layout, masonry
svelte-stripe-js
Everything you need to add Stripe Elements to your Svelte project
Stars: ✭ 139 (+531.82%)
Mutual labels:  svelte, svelte-kit
Shuffle
Categorize, sort, and filter a responsive grid of items
Stars: ✭ 2,170 (+9763.64%)
Mutual labels:  layout, masonry
Vue Masonry
💠 Vue.js directive for masonry blocks layouting ✅
Stars: ✭ 509 (+2213.64%)
Mutual labels:  layout, masonry
Driveway
pure CSS masonry layouts
Stars: ✭ 607 (+2659.09%)
Mutual labels:  layout, masonry
Flexlib
FlexLib是一个基于flexbox模型,使用xml文件进行界面布局的框架,融合了web快速布局的能力,让iOS界面开发像写网页一样简单快速
Stars: ✭ 1,569 (+7031.82%)
Mutual labels:  layout, masonry
React Xmasonry
Simple, minimalistic and featured native masonry layout for React JS.
Stars: ✭ 62 (+181.82%)
Mutual labels:  layout, masonry
masonry-css
Create mosaic grid, like masonry, with css only
Stars: ✭ 17 (-22.73%)
Mutual labels:  layout, masonry
type-kana
A quiz app to help you learn hiragana and katakana, the Japanese syllabaries
Stars: ✭ 21 (-4.55%)
Mutual labels:  svelte, svelte-kit
tikz
Random collection of standalone TikZ images
Stars: ✭ 87 (+295.45%)
Mutual labels:  svelte, svelte-kit
Svelte Grid
A responsive, draggable and resizable grid layout, for Svelte.
Stars: ✭ 473 (+2050%)
Mutual labels:  layout, svelte
programmingtil-svelte
No description or website provided.
Stars: ✭ 59 (+168.18%)
Mutual labels:  svelte, svelte-kit
svelte-commerce
Svelte ecommerce - Headless, Authentication, Cart & Checkout, TailwindCSS, Server Rendered, Proxy + API Integrated, Animations, Stores, Lazy Loading, Loading Indicators, Carousel, Instant Search, Faceted Filters, Typescript, Open Source, MIT license. 1 command deploy to your own server, 1 click deploy to netlify.
Stars: ✭ 695 (+3059.09%)
Mutual labels:  svelte, netlify
egjs-grid
A component that can arrange items according to the type of grids
Stars: ✭ 188 (+754.55%)
Mutual labels:  layout, masonry
portfolio-svelte
My over-complicated personal site. A place to show off work and writing, and a place to try weird stuff.
Stars: ✭ 24 (+9.09%)
Mutual labels:  svelte, netlify
website
Gitpod website and documentation
Stars: ✭ 233 (+959.09%)
Mutual labels:  svelte, netlify
UmaSupporter.WebClient
🏃🏽‍♀️ 우마무스메 육성 도우미 '우마서포터'의 프론트엔드 애플리케이션입니다.
Stars: ✭ 14 (-36.36%)
Mutual labels:  netlify
bad-cards-game
Bad Cards Game
Stars: ✭ 23 (+4.55%)
Mutual labels:  netlify
angular-bricklayer
AngularJS module for ademilter's bricklayer, a lightweight & independent cascading grid layout library
Stars: ✭ 42 (+90.91%)
Mutual labels:  layout

Svelte Bricks
 Svelte Bricks

Tests NPM version Netlify Status pre-commit.ci status

Naive implementation in Svelte without column balancing.

Live demo

Installation

yarn add -D svelte-bricks

Usage

The kitchen sink for this component looks something like this:

<script>
  import Masonry from 'svelte-bricks'

  let nItems = 30
  $: items = [...Array(nItems).keys()]

  let [minColWidth, maxColWidth, gap] = [200, 800, 20]
  let width, height
</script>

Masonry size: <span>{width}px</span> &times; <span>{height}px</span> (w &times;
h)

<Masonry
  {items}
  {minColWidth}
  {maxColWidth}
  {gap}
  let:item
  bind:width
  bind:height
>
  <Some {item} />
</Masonry>

Note: On non-primitive items, i.e. if items is an array of objects, this component by default tries to access a key named 'id' on each item. This value is used to tell items apart in the keyed {#each} block that renders the masonry layout. Without it, Svelte could not avoid duplicates when new items are added or existing ones rearranged. Read the Svelte docs for details. To change the name of the identifier key, use the idKey prop. You can also pass in a custom function as getId that should map items to unique IDs.

Hint: Balanced columns can be achieved even with this simple implementation if masonry items are allowed to stretch to the column height.

Props

Masonry.svelte expects an array of items as well as a <slot /> component used to render each of the items. The array can contain whatever data (objects, strings, numbers) as long as the slot component knows how to handle it.

Additional optional props are:

  • items: (string | number | object)[]: required
  • minColWidth: number = 330 (in px)
  • maxColWidth: number = 500 (in px)
  • gap: number = 20 (in px)
  • masonryWidth: number = 0: Bound to the masonry divs width (in px).
  • masonryHeight: number = 0: Bound to the masonry divs height (in px).
  • idKey: string = 'id': Name of the attribute to use as identifier if items are objects.
  • getId: (item) => string | number: Custom function that maps masonry items to unique IDs.
  • animate: boolean = true: Whether to FLIP-animate masonry items when viewport resizing or other events cause items to rearrange.
  • style: string = '': Inline styles that will be applied to the top-level div.masonry.
  • duration: number = 200: Transition duration in milli seconds when masonry items are rearranged or added/removed. Set to 0 to disable transitions.
  • class: string = '': Applies to the outer div wrapping all masonry columns. For use with CSS frameworks like Tailwind.
  • columnClass: string = '': Applies to each column div.

Styling

Besides inline CSS which you can apply through the style prop, the following :global() CSS selectors can be used for fine-grained control of wrapper and column styles:

:global(div.masonry) {
  /* top-level wrapper div */
}
:global(div.masonry div.col) {
  /* each column in the masonry layout */
}
Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].