SVG Colk Board で Vuex を使ってみた話
この記事は賞味期限切れです。(更新から1年が経過しています)
先日リリースしたWebアプリ「SVG Colk Board」の紹介と、 その中身の話を少し綴っておきます。
SVG Colk Board を作った話
これは何?
Illustrator 上で図をコピーしてテキストエディタにペーストすると、SVGが出力されます。 しかし、そこで出力されるSVGは不要な記述も多く、末尾に付加されている謎文字のおかげで正常に表示されません。
これらをクリーンに最適化する為に作ったのが SVG Colk Board です。
使い方
- Illustrator上で図をコピーする
- それを SVG Colk Board 上でペーストする
- 配置された図を選択すると「SVG」「DataURI」ボタンが表示される
- 「SVG」「DataURI」のボタンをクリックすると、それぞれ最適化された結果がクリップボードにコピーされる
- 結果をテキストエディタにペースト
- ペーストした図のデータは localStorage に保存されるので、ブラウザを閉じた後も保持されます
- つまり貼り付けられる図の数は localStorage の容量依存です
- もちろんブラウザをまたいでは保持されません
SVG Colk Board の中身
このアプリケーションは Vue.js で作られています。 そして Vue と共に利用しているのが Vuex と vuex-persistedstate です。
Vuex
ここでは詳しい説明を省きますが、 Vuexとは、中規模以上のアプリケーション開発向けの状態管理ライブラリで、 公式ではこのように説明されています。
Vuex は Vue.js アプリケーションのための 状態管理パターン + ライブラリです。 これは予測可能な方法によってのみ状態の変異を行うというルールを保証し、アプリケーション内の全てのコンポーネントのための集中型のストアとして機能します。
https://vuex.vuejs.org/ja
簡潔に言うと、状態管理にストア(store)という概念を導入する為のライブラリです。 以下、ものすごくざっくりとした説明をします。
Vue.js のコンポーネントは各々が持つ data の値を基にビューを構築・描画し、必要に応じて処理を行います。 store というのはその data に似た振る舞いをしますが、 data が値へのアクセスで直接変更出来るのに対し、 store はセッターのようなメソッドを介してのみ値を変更する事ができ、 それにより値を保護し、変更を集中管理する事ができます。
ざっくりしすぎていてあまりイメージし辛いかと思いますので、下記ページを参考にしてください。
先に述べた通り、中規模以上のプロジェクトでなければあまり恩恵にあずかれず、冗長になるだけと感じるかもしれません。 しかし、Vue.js を採用するという事は、ある程度の規模のあるプロジェクトとなる予測が立つとも言えるので、 転ばぬ先の Vuex を問答無用で入れてしまうのも選択肢の一つだと考えられます。
vuex-persistedstate
今回作った様なミニマムなアプリケーションでは正直Vuexは不向きな気がします。 それでもVuexを導入したのは、半分はVuexで習作してみるため、 もう半分はこの vuex-persistedstate を使うためです。
vuex-persistedstate は、Vuexのストアの中身(state)をまるっとlocalStorageに保存してくれるプラグインです。 Vuexでストアを書く時にちょっとインポートしてやれば簡単に導入できます。 (下記はREADMEのコードそのままです)
import createPersistedState from "vuex-persistedstate";
const store = new Vuex.Store({
// ...
plugins: [createPersistedState()]
});
Code language: JavaScript (javascript)
これで(同じブラウザで見る限りは)ページの状態を永続化できるという寸法です。 なんて便利なんでしょうか!
まとめ
もともとはイラレが吐き出すSVGを最適化する事しか考えてなかったのですが、 ちょうどよいお題だと思って Vuex を使って習作してみたというお話でした。 このアプリで使用している netlify の知見も少しずつたまり始めたので、それはまたいずれ。
コメント
Step Into the Casino PinUp Universe
The hallmark of every Pin-Up Casino in Canada is its retro-chic interior. Visitors are transported back to mid-century glamour, where vintage posters, pin-up art, and bold neon signs set the tone. Staff uniforms are styled to match the era, enhancing the immersive feel of the space. Whether you're stepping into a land-based location or logging on to the online platform, the atmosphere oozes sophistication and playful nostalgia.
Games That Blend Past and Present
Despite their vintage flair, PinUp venues offer an impressive lineup of contemporary games. Players can enjoy timeless table games like poker, roulette, and blackjack, or dive into high-tech video slots with immersive sound and animation. Whether you're into classic three-reel slots or crave something flashier, you'll find it at Casino PinUp — with bets suited for any bankroll.
Fan Favorites: Sweet Bonanza & Aviator
Two games that consistently stand out in the Pin-Up Casino Online catalog are Sweet Bonanza and Aviator. Sweet Bonanza brings a candy-coated experience to the screen with vibrant visuals, a catchy soundtrack, and rewarding bonus features — making it a favorite among casual players and seasoned gamblers. Aviator, meanwhile, delivers a thrilling ride through the skies, combining fast-paced action with smart strategy. Both games capture the spirit of fun and adventure that defines the Pin-Up Casino Canada identity.
Changing the Canadian Casino Game
Casinos like Pin-Up Casino Canada are not just venues — they’re experiences. Their retro-meets-modern vibe is bringing a fresh perspective to gaming in Canada. By targeting a diverse audience that includes nostalgic boomers, curious Gen Xers, and entertainment-hungry millennials, the brand is revitalizing interest in casino entertainment. From Manitoba to Ottawa, these casinos are helping redefine the landscape of Canadian gambling.
Pin-Up Casino is more than a gaming hub — it’s a lifestyle destination. Fusing the glamour of the past with the innovations of the present, it creates an experience that’s visually captivating and thrilling to play. With continuous expansion and a growing fan base, PinUp Casino is well-positioned to become a major force in the future of Canada’s gambling industry.
Desde el registro, que es rapido, sencillo, gratuito, hasta el momento de cobrar tus ganancias, todo funciona de manera agil, transparente, profesional. Con solo registrarte en Pinup Chile, ya puedes acceder a bonos de bienvenida, saldo extra, giros gratuitos y promociones especiales, que te permitiran comenzar a jugar con ventaja desde el primer giro.
Si deseas empezar a jugar ahora mismo, simplemente visita el sitio oficial de Pin-Up Casino Chile https://pinupcasinopinup.cl/ para obtener tus bonos de bienvenida inmediatamente.
A medida que exploras el catalogo de juegos, veras que hay miles de tragamonedas. No importa si prefieres el casino en vivo, aqui siempre hay algo nuevo para ti.
Muchos jugadores destacan el sistema de pagos rapidos, retiros inmediatos, depositos seguros. Y es que Pin-Up Casino Chile ofrece multiples metodos adaptados a los jugadores chilenos, permitiendo que puedas cobrar tus ganancias sin demoras.
Ademas, siempre tendras acceso a soporte profesional, para resolver cualquier duda o consulta de forma rapida, amable, eficiente. Ya sea para resolver un problema tecnico, consultar sobre promociones, o solicitar ayuda con un retiro, el equipo de Pin-Up Chile siempre esta disponible.
Lo mejor es que puedes jugar donde quieras, cuando quieras, desde cualquier dispositivo. La plataforma esta completamente optimizada para moviles, tablets, computadoras, laptops, cualquier pantalla, para que puedas disfrutar de tus juegos favoritos en casa, en el trabajo, o mientras viajas.
Para muchos jugadores en Chile, Pin-Up Casino se ha convertido en el lugar ideal donde vivir la emocion del casino online. Las ofertas permanentes, promociones personalizadas, programas VIP y constantes actualizaciones de juegos hacen que cada dia tengas nuevas razones para regresar.
Si estas buscando un casino con bonos atractivos y juegos de calidad, Pin-Up Casino Chile es el lugar donde la diversion y el dinero real se encuentran.
Hoy mismo puedes registrarte, recibir tu bono, girar tus primeros slots y comenzar a ganar. La experiencia de casino online en Chile empieza aqui, en Pin-Up.
<b>ever viewed</b> earlier - greatly current in health discipline research!
<b>Completely safe</b> and potent - likewise enhanced passion as still increased penile stiffness!
<a href="https://psee.io/7qlgd7" rel="nofollow ugc"><b>Enhance volume in personal releases now right now!</b></a>
If you're looking for a complete online betting experience in Canada, Pin-Up-Canada.bet offers everything a bettor needs. With a wide range of sports betting, this site delivers unmatched variety for every type of player.
At Pin-Up Canada Online, you’ll find exciting casino slots. Whether you enjoy hockey odds, Pin-Up-Canada.bet provides huge payouts.
From the moment you create your free profile, you unlock free bets to kick-start your journey. New members at Pin-Up Canada Online Platform receive rewarding first deposit offers immediately after registration.
Whether you’re playing from Quebec City, Pin-Up-Canada.bet offers secure withdrawals that ensure safe transactions.
The entire platform is fully optimized for mobile and desktop. Players can play casino games on mobile with seamless navigation.
Every day, more Canadians experience the thrill at Pin-Up Canada and enjoy huge jackpots. Whether you're into esports tournaments, Pin-Up-Canada.bet delivers top-tier entertainment.
Create your account at https://pin-up-canada.bet/ and experience Canada’s best online betting platform!