<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0" xmlns:cc="http://cyber.law.harvard.edu/rss/creativeCommonsRssModule.html">
    <channel>
        <title><![CDATA[Stories by Ahmet Emre Kılınç on Medium]]></title>
        <description><![CDATA[Stories by Ahmet Emre Kılınç on Medium]]></description>
        <link>https://medium.com/@ahmetemrekilinc?source=rss-77db856831a6------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*jwWQB97urnO_hN-wLa66gA.jpeg</url>
            <title>Stories by Ahmet Emre Kılınç on Medium</title>
            <link>https://medium.com/@ahmetemrekilinc?source=rss-77db856831a6------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Sat, 05 Dec 2026 00:51:45 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@ahmetemrekilinc/feed" rel="self" type="application/rss+xml"/>
        <webMaster><![CDATA[yourfriends@medium.com]]></webMaster>
        <atom:link href="http://medium.superfeedr.com/" rel="hub"/>
        <item>
            <title><![CDATA[How to Make a Circular Text in React using react-curved-text]]></title>
            <link>https://medium.com/codable/how-to-make-a-circular-text-in-react-using-react-curved-text-4257b645fc8e?source=rss-77db856831a6------2</link>
            <guid isPermaLink="false">https://medium.com/p/4257b645fc8e</guid>
            <category><![CDATA[obss-codable-english]]></category>
            <category><![CDATA[react]]></category>
            <category><![CDATA[circulartext]]></category>
            <category><![CDATA[curved-text]]></category>
            <dc:creator><![CDATA[Ahmet Emre Kılınç]]></dc:creator>
            <pubDate>Tue, 04 Oct 2022 16:50:17 GMT</pubDate>
            <atom:updated>2024-02-12T10:49:17.742Z</atom:updated>
            <content:encoded><![CDATA[<p>In HTML, you can curve text around a circle or inside a circle by using <a href="https://developer.mozilla.org/en-US/docs/Web/SVG/Element/path">&lt;path&gt;</a>, <a href="https://developer.mozilla.org/en-US/docs/Web/SVG/Element/text">&lt;text&gt;</a> and <a href="https://developer.mozilla.org/en-US/docs/Web/SVG/Element/textPath">&lt;textPath&gt;</a> tags, inside a <a href="https://developer.mozilla.org/en-US/docs/Web/SVG/Element/svg">&lt;svg&gt;</a> element.</p><p>For example, this SVG element:</p><pre>&lt;svg viewBox=&quot;0 0 500 500&quot;&gt;<br>  &lt;path id=&quot;curve&quot; d=&quot;m 20 20 a 30 30 30 1 1 50 50&quot; style=&quot;fill: red&quot; /&gt;<br>  &lt;text width=&quot;500&quot;&gt;<br>    &lt;textPath xlink:href=&quot;#curve&quot;&gt;<br>      curved text<br>    &lt;/textPath&gt;<br>  &lt;/text&gt;<br>&lt;/svg&gt;</pre><p>will produce this graphics:</p><figure><img alt="curved-text-example" src="https://cdn-images-1.medium.com/max/152/1*PAylCpzZTPb6mg7aib-Jyw.png" /></figure><p>In this example, the only real obstacle for the developer is to find the suitable value for the <strong>d</strong> attribute of the <strong>path</strong> tag.</p><pre>d=&quot;m 20 20 a 30 30 30 1 1 50 50&quot;</pre><p>If you are using <strong>React.js</strong>,<strong> </strong>curved texts can easily be created using <a href="https://www.npmjs.com/package/react-curved-text"><strong>react-curved-text</strong></a> add-on:</p><p>To install the library;</p><p>using npm:</p><pre>npm install react-curved-text</pre><p>Or using yarn:</p><pre>yarn add react-curved-text</pre><p>And then you need to import <strong>ReactCurvedText</strong> component and use it like:</p><pre>import ReactCurvedText from &quot;react-curved-text&quot;;<br><br>const MyComponent = () =&gt; {<br>  return (<br>    &lt;ReactCurvedText<br>      width={370}<br>      height={300}<br>      cx={190}<br>      cy={120}<br>      rx={100}<br>      ry={100}<br>      startOffset={100}<br>      text=&quot;curved text&quot;<br>    /&gt;<br>  );<br>};<br><br>export default MyComponent;</pre><p>It will give you the output:</p><figure><img alt="react-curved-text-1" src="https://cdn-images-1.medium.com/max/152/1*uyxKwTIhKX6kyMXHMTWHEg.png" /></figure><p>You can also reverse the curving direction by simply adding <strong>reversed</strong> prop:</p><pre>reversed={true}</pre><p>It will give you the output:</p><figure><img alt="react-curved-text reverser" src="https://cdn-images-1.medium.com/max/152/1*ThV2COZW2f82UBgbAd3h4Q.png" /></figure><p>For more information and live examples, you can visit <a href="https://obss.github.io/react-curved-text/">react-curved-text demo page</a>.</p><p>You can also <a href="https://stackblitz.com/edit/react-curved-text-demo">try a live example on StackBlitz.</a></p><p>As you can see in the example code, there is no need to find or define any <strong>d</strong> attribute for an <strong>svg</strong> path. All you need to do is; define and pass <strong>rx</strong> (x radius), <strong>ry</strong> (y radius), <strong>cx</strong> (center position of x), <strong>cy</strong> (center position of y), <strong>width</strong> (width of the SVG), <strong>height</strong> (height of the SVG), <strong>text</strong> (the text to be curved) props.</p><figure><img alt="featured-image" src="https://cdn-images-1.medium.com/max/800/1*THxGn-9z_e2oiFgUGyYIDQ.png" /></figure><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=4257b645fc8e" width="1" height="1" alt=""><hr><p><a href="https://medium.com/codable/how-to-make-a-circular-text-in-react-using-react-curved-text-4257b645fc8e">How to Make a Circular Text in React using react-curved-text</a> was originally published in <a href="https://medium.com/codable">Codable</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Easily Validate React Forms using react-validatable-form]]></title>
            <link>https://medium.com/codable/easily-validate-react-forms-using-react-validatable-form-734724ae7124?source=rss-77db856831a6------2</link>
            <guid isPermaLink="false">https://medium.com/p/734724ae7124</guid>
            <category><![CDATA[react-hook]]></category>
            <category><![CDATA[validator]]></category>
            <category><![CDATA[validation]]></category>
            <category><![CDATA[obss-codable-english]]></category>
            <category><![CDATA[react]]></category>
            <dc:creator><![CDATA[Ahmet Emre Kılınç]]></dc:creator>
            <pubDate>Tue, 04 Oct 2022 16:35:15 GMT</pubDate>
            <atom:updated>2024-02-12T10:43:58.351Z</atom:updated>
            <content:encoded><![CDATA[<p>Validating large forms is a complex challenge in front-end projects. There will probably be many things to consider (and handle), like:</p><ul><li>Validating values, immediately after every value change.</li><li>Hiding validation results before the form is submitted.</li><li>Displaying the validation error when the element looses focus.</li><li>Conditional validation of fields.</li><li>Validating each element of a list using the same rule.</li><li>Building custom reusable rules (to be used anywhere in the app).</li><li>Localization and customization of error messages for the same validation rules.</li><li>Focusing on the first invalid element (one with a validation error), following form submission.</li></ul><p>In react projects, all these requirements can easily be managed via the <a href="https://www.npmjs.com/package/react-validatable-form"><strong>react-validatable-form</strong></a> library.</p><p>In order to use react-validatable-form in your project, you should first, add it to the project.</p><p>If you are using npm, run:</p><pre>npm install react-validatable-form</pre><p>If you are using yarn, run:</p><pre>yarn add react-validatable-form</pre><p>After that, you need to wrap your app with <strong>ReactValidatableFormProvider</strong>:</p><pre>import { ReactValidatableFormProvider } from &#39;react-validatable-form&#39;;</pre><pre>//....<br>    return &lt;ReactValidatableFormProvider&gt;<br>                &lt;App /&gt;<br>        &lt;/ReactValidatableFormProvider&gt;;</pre><p>Next, you can use <strong>useValidatableForm</strong> hook anywhere in your app:</p><pre>import { useValidatableForm } from &#39;react-validatable-form&#39;;<br>import TextField from &#39;<a href="http://twitter.com/mui/material">@mui/material</a>/TextField&#39;;</pre><pre>//....<br><br>const initialFormData = {};<br>const rules = [{ path: &#39;val&#39;, ruleSet: [{ rule: &#39;required&#39; }] }];</pre><pre>//....</pre><pre>const { isValid, formData, setPathValue, getValue, getError } = useValidatableForm({<br>        rules,<br>        initialFormData,<br>    });</pre><pre>return &lt;TextField<br>        error={!!getError(&#39;val&#39;)}<br>        helperText={getError(&#39;val&#39;) || &#39; &#39;}<br>        <br>        type=&quot;text&quot;<br>        value={getValue(&#39;val&#39;) || &#39;&#39;}<br>        onChange={(e) =&gt; setPathValue(&#39;val&#39;, e.target.value)}<br>    /&gt;;</pre><p>The output of this code on initial render is:</p><figure><img alt="rvf-1" src="https://cdn-images-1.medium.com/max/231/1*prOmUagjL3hcaOQ7wydsvw.png" /></figure><p><a href="https://obss.github.io/react-validatable-form-demo/library-api/use-validatable-form"><strong>useValidatableForm</strong></a> is a <a href="https://reactjs.org/docs/hooks-intro.html">React hook</a> that manages the validations of input elements in a form. In this example, it takes 2 parameters:</p><ul><li><strong>rules</strong>: an array that contains the rules to be checked on the form,</li><li><strong>initialFormData</strong>: the default values of the form datum, preset in the initial rendering process.</li></ul><p>In this example, it returns 5 parameters:</p><ul><li><strong>isValid</strong>: boolean flag, returning whether the form is valid or not at that moment,</li><li><strong>formData</strong>: form data that contains values of all <a href="https://obss.github.io/react-validatable-form-demo/library-api/path"><strong>path</strong>s</a> in the form,</li><li><strong>setPathValue</strong>: function to update the value of the given <strong>path</strong>,</li><li><strong>getValue</strong>: retrieves the current value of the given <strong>path</strong>,</li><li><strong>getError</strong>: retrieves the current error message of the given <strong>path.</strong></li></ul><p>Since end users generally prefer not to see any errors until the form is submitted, it is better to hide them, before. For this, we can set <a href="https://obss.github.io/react-validatable-form-demo/advanced/hide-before-submit"><strong>hideBeforeSubmit</strong></a> prop to <strong>true;</strong></p><p>either in <a href="https://obss.github.io/react-validatable-form-demo/library-api/use-validatable-form"><strong>useValidatableForm</strong></a><strong> </strong>(form-scoped):</p><pre>useValidatableForm({<br>        rules,<br>        initialFormData,<br>        hideBeforeSubmit: true<br>});</pre><p>or in <a href="https://obss.github.io/react-validatable-form-demo/library-api/react-validatable-form-provider"><strong>ReactValidatableFormProvider</strong></a> (app-scoped):</p><pre>&lt;ReactValidatableFormProvider hideBeforeSubmit={true}&gt;<br>   &lt;App /&gt;<br>&lt;/ReactValidatableFormProvider&gt;</pre><p>Similarly, end users may want to see the errors when they focus on a component. For this, we can set <a href="https://obss.github.io/react-validatable-form-demo/advanced/show-after-blur"><strong>showAfterBlur</strong></a> prop to <strong>true</strong>;</p><p>either in <a href="https://obss.github.io/react-validatable-form-demo/library-api/use-validatable-form"><strong>useValidatableForm</strong></a><strong> </strong>(form-scoped):</p><pre>useValidatableForm({<br>        rules,<br>        initialFormData,<br>        hideBeforeSubmit: true,<br>        showAfterBlur: true<br>});</pre><p>or in <a href="https://obss.github.io/react-validatable-form-demo/library-api/react-validatable-form-provider"><strong>ReactValidatableFormProvider</strong></a> (app-scoped):</p><pre>&lt;ReactValidatableFormProvider hideBeforeSubmit={true} showAfterBlur={true}&gt;<br>   &lt;App /&gt;<br>&lt;/ReactValidatableFormProvider&gt;</pre><p>For enhanced user experience, focusing on the first error after the form is submitted, can be an indispensable feature. For this, we can set <a href="https://obss.github.io/react-validatable-form-demo/advanced/focus-to-error-after-submit"><strong>focusToErrorAfterSubmit</strong></a> prop to <strong>true</strong>;</p><p>either in <a href="https://obss.github.io/react-validatable-form-demo/library-api/use-validatable-form"><strong>useValidatableForm</strong></a><strong> </strong>(form-scoped):</p><pre>useValidatableForm({<br>        rules,<br>        initialFormData,<br>        hideBeforeSubmit: true,<br>        showAfterBlur: true,<br>        focusToErrorAfterSubmit: true<br>});</pre><p>or in <a href="https://obss.github.io/react-validatable-form-demo/library-api/react-validatable-form-provider"><strong>ReactValidatableFormProvider</strong></a> (app-scoped):</p><pre>&lt;ReactValidatableFormProvider hideBeforeSubmit={true} showAfterBlur={true} focusToErrorAfterSubmit={true}&gt;<br>   &lt;App /&gt;<br>&lt;/ReactValidatableFormProvider&gt;</pre><p>Note that we need to set the <strong>id</strong> attribute of the elements to be the same as the value of the <strong>path</strong> property of the corresponding rules, otherwise the hook can fail to find the element in DOM.</p><p>Beyond that, in most cases, we need to consider HTML components that are not focusable (has no input tag to be focused on), such as checkbox, radio button, table, … etc. For this, we can use <a href="https://obss.github.io/react-validatable-form-demo/customizations/custom-element-focus-handler"><strong>elementFocusHandler</strong></a> prop;</p><p>either in <a href="https://obss.github.io/react-validatable-form-demo/library-api/use-validatable-form"><strong>useValidatableForm</strong></a><strong> </strong>(form-scoped):</p><pre>const myCustomElementFocusHandler = (elementId) =&gt; {<br>    const element = document.getElementById(elementId);<br>    if (!element) {<br>        console.warn(`Dom element with id ${elementId} could not be found`);<br>    } else {<br>        const parentElement = element.parentElement;<br>        const grantParentElement = parentElement.parentElement;<br>        grantParentElement.classList.add(&#39;element-shaking&#39;);<br>        element.focus();<br>        setTimeout(() =&gt; {<br>            grantParentElement.classList.remove(&#39;element-shaking&#39;);<br>        }, 600);<br>    }<br>};</pre><pre>useValidatableForm({<br>        rules,<br>        initialFormData,<br>        hideBeforeSubmit: true,<br>        showAfterBlur: true,<br>        focusToErrorAfterSubmit: true,<br>        elementFocusHandler: myCustomElementFocusHandler<br>});</pre><p>or in <a href="https://obss.github.io/react-validatable-form-demo/library-api/react-validatable-form-provider"><strong>ReactValidatableFormProvider</strong></a> (app-scoped):</p><pre>const myCustomElementFocusHandler = (elementId) =&gt; {<br>    const element = document.getElementById(elementId);<br>    if (!element) {<br>        console.warn(`Dom element with id ${elementId} could not be found`);<br>    } else {<br>        const parentElement = element.parentElement;<br>        const grantParentElement = parentElement.parentElement;<br>        grantParentElement.classList.add(&#39;element-shaking&#39;);<br>        element.focus();<br>        setTimeout(() =&gt; {<br>            grantParentElement.classList.remove(&#39;element-shaking&#39;);<br>        }, 600);<br>    }<br>};</pre><pre>&lt;ReactValidatableFormProvider hideBeforeSubmit={true} showAfterBlur={true} focusToErrorAfterSubmit={true} elementFocusHandler={myCustomElementFocusHandler}&gt;<br>   &lt;App /&gt;<br>&lt;/ReactValidatableFormProvider&gt;</pre><p>This code shows an example of visualizing the form validation by adding a temporary <em>shaking effect</em> (using CSS) to the element with the first validation error, after the form is submitted.</p><p>This screenshot is an example output of this code:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*NhfaOPZT_ADR2dC5LlAbRQ.gif" /><figcaption>Custom elementFocusHandler with shaking effect</figcaption></figure><p>The default rules defined in <strong>react-validatable-form</strong> are:</p><ul><li><strong>required</strong>: checks if the given value is not one of the values: <em>undefined</em>, <em>null</em>, <em>empty string</em><strong>,</strong> or <em>empty array</em></li><li><strong>number</strong>: checks if the given value is a valid number</li><li><strong>length</strong>: checks the length of a string</li><li><strong>listSize</strong>: checks the length of an array</li><li><strong>date</strong>: checks if the given value is a valid date</li><li><strong>email</strong>: checks if the given value is a valid email</li><li><strong>url</strong>: checks if the given value is a valid URL</li><li><strong>iban</strong>: checks if the given value is a valid IBAN</li><li><strong>equality</strong>: checks if the given value is equal to the comparison value</li><li><strong>includes</strong>: checks if the given value includes the comparison value</li><li><strong>regex</strong>: checks if the given value is a valid string matching the given <a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Guide/Regular_Expressions">regex</a></li><li><strong>unique</strong>: rule checks if non-unique values exist on a <a href="https://obss.github.io/react-validatable-form-demo/library-api/path">listPath</a></li></ul><p>Other than these rules, any custom rule can be defined inside of a component, as a function:</p><pre>const customRule = (ruleParams) =&gt; {<br>    const { value } = ruleParams;<br>    if (value &amp;&amp; (!value.includes(&#39;g&#39;) || value.length &lt; 5)) {<br>        return &#39;this field should include letter `g` and its length should be greater than 5&#39;;<br>    }<br>    return null;<br>};</pre><pre>const rules = [{ path: &#39;val&#39;, ruleSet: [&#39;required&#39;, { rule: customRule }] }];</pre><p>A non-empty return value for a custom rule means a validation error.</p><p>Similarly, custom rules can also be made app-scoped by passing them to the <strong>ReactValidatableFormProvider</strong> via <strong>customRules</strong> prop with a unique rule name:</p><pre>const MyCustomRuleFunction = (ruleParams) =&gt; {<br>    const { value } = ruleParams;</pre><pre>if (!value) {<br>        return &#39;this field is a required field&#39;;<br>    }</pre><pre>if (!value.includes(&#39;a&#39;) &amp;&amp; value.length &lt; 5) {<br>        return `text ${value} should either include letter &#39;a&#39; or its length should be greater than 4`;<br>    }</pre><pre>return null;<br>};</pre><pre>const customRules = {<br>    myCustomRule: MyCustomRuleFunction<br>};</pre><pre>&lt;ReactValidatableFormProvider customRules={customRules}&gt;<br>   &lt;App /&gt;<br>&lt;/ReactValidatableFormProvider&gt;</pre><p>In the above example, <strong>myCustomRule</strong> rule can be used anywhere in the app, just like the default rules; <strong>required</strong>, <strong>number,</strong> … etc.</p><p>By default, validation rules are run whenever there is a change in the corresponding <strong>path</strong>. If the rule depends on a condition, we can use <a href="https://obss.github.io/react-validatable-form-demo/customizations/conditional-rules"><strong>enableIf</strong> &amp; <strong>disableIf</strong></a> parameters in the rule definition:</p><pre>const rules = [<br>    {<br>        path: &#39;val1&#39;,<br>        ruleSet: [<br>            {<br>                rule: &#39;required&#39;,<br>                disableIf: (formData) =&gt; formData[&#39;disableVal1Rule&#39;],<br>            },<br>        ],<br>        dependantPaths: [&#39;disableVal1Rule&#39;],<br>    },<br>    {<br>        path: &#39;val2&#39;,<br>        ruleSet: [<br>            {<br>                rule: &#39;required&#39;,<br>                enableIf: (formData) =&gt; formData[&#39;enableVal2Rule&#39;],<br>            },<br>        ],<br>        dependantPaths: [&#39;enableVal2Rule&#39;],<br>    },<br>];</pre><p>We need to use <strong>dependantPaths</strong> parameter to force the rule to run whenever there is a change on the paths other than the original <em>path</em>.</p><p><strong>dependantPaths </strong>parameter is also required, if the compared value is not static, which means that it is a dynamic value depending on another value in the <strong>formData</strong>:</p><pre>const rules = [<br> {<br>  path: &#39;val&#39;, <br>  ruleSet: [<br>   {<br>    rule: &#39;number&#39;, <br>    greaterThan: (formData) =&gt; formData[&#39;comparisonValue&#39;]<br>   }<br>  ],<br>  dependantPaths: [&#39;comparisonValue&#39;]<br> }<br>];</pre><p>For more information and live examples, you can visit <a href="https://obss.github.io/react-validatable-form-demo">react-validatable-form-demo</a> (for various customizations of <a href="https://www.npmjs.com/package/react-validatable-form"><strong>react-validatable-form</strong></a> library).</p><p>You can also <a href="https://stackblitz.com/edit/react-validatable-form">try a live example on StackBlitz.</a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=734724ae7124" width="1" height="1" alt=""><hr><p><a href="https://medium.com/codable/easily-validate-react-forms-using-react-validatable-form-734724ae7124">Easily Validate React Forms using react-validatable-form</a> was originally published in <a href="https://medium.com/codable">Codable</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
    </channel>
</rss>