Giter VIP home page Giter VIP logo

gaming-links's Introduction

gaming-links

My gaming profiles across different platforms.

References

The Net Ninja (Shaun Pelling)

Notes

Svelte

  • Svelte = compiler (not a framework) + reactivity + components.
  • Svelte compiles the code for production at build time into a (single) JavaScript bundle. So, no extra scripts/libraries are shipped to production. The Svelte library is not deployed as in React and Vue.
  • App.svelte: root component.
  • Handler functions can take the event object.
  • Data binding:
    • The bind:property directive is a two-way data binding under the hood. So, <input type="text" bind:value={colorVariable}> is similar to <input type="text" on:input={handleInputFunction} value={colorVariable}>. In practice, the input element changes the variable and the changes will be reflected on the page. If the variable is changed elsewhere (via a button, for example), the value will also be updated in the input element.
  • $: console.log(colorVariable); is an example of a reactive statement. Use $: {...} for a code block.
  • {#each array as arrayElement (arrayElement.key)}...{/each} (key is important if you need to manipulate the data). This block can also have an {:else} clause, which is rendered if array is empty.
  • <button on:click={() => handleClick(object.id)}>Delete</button> or <button on:click={(event) => handleClick(event, object.id)}>Delete</button> (inline event handler). This is useful for deleting an element from an array by its identifier within an each block (assuming there is a button for each element), for example. In other words, this is useful if the handler function needs to take arguments in addition to event.
  • Event forwarding:
    • If the on: directive (e.g., on:click) is used without a value, the component will forward the event. In this way, a consumer (parent component) of the component (child component) can listen for it. In other words, you can define a handler function in App.svelte, assuming the component is used here, as there is another element, such as a button, that is used to show/hide this component. Example:
      • App.svelte file: <Modal ... on:click={toggleModal} /> and <button on:click={toggleModal}>...</button>.
      • Modal.svelte file: <div ... on:click>...</div>.
    • The self event modifier (e.g., on:click|self) is useful for a modal since the handler is only triggered if event.target is the element itself. In practice, this allows the modal to be closed only if there is a click outside the message container (a child <div>), on the part that is faded, for example.
  • In Svelte, when we bind to a number input (e.g., <input type="number" bind:value={numVariable}>), the input value is coerced. In this way, the associated variable is a number, not a string.
  • let arrayVariable = []; + bind:group={arrayVariable} for radio and checkbox inputs (example).
  • Dispatching custom events:
    • Event forwarding is for events, not data (use createEventDispatcher instead).
    • Events dispatched (custom event + data) from child components can be listened to in their parent (e.g., <ChildComponent on:name={handlerFunction} />). The data is available on the detail property of the event object.

CSS

  • crimson instead of red (color keywords).
  • main { max-width: 960px; margin: 40px auto; }.

Misc

gaming-links's People

Contributors

joaopalmeiro avatar

Watchers

 avatar

gaming-links's Issues

Implement wave hand

References:

Snippet

import styled from '@emotion/styled';
import tw from 'twin.macro';

export const Wave = styled.span`
	&:hover {
		${tw`inline-block`}
		animation: wave 2.25s ease-in-out infinite;
		transform-origin: 70% 70%;
	}

	@keyframes wave {
		0% {
			transform: rotate(0deg);
		}
		10% {
			transform: rotate(14deg);
		}
		20% {
			transform: rotate(-8deg);
		}
		30% {
			transform: rotate(14deg);
		}
		40% {
			transform: rotate(-4deg);
		}
		50% {
			transform: rotate(10deg);
		}
		60% {
			transform: rotate(0deg);
		}
		100% {
			transform: rotate(0deg);
		}
	}
`;

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.